Skip to content

Validate BCP47 language tags with a regex#873

Open
azmeuk wants to merge 1 commit intoauthlib:mainfrom
azmeuk:bcp47
Open

Validate BCP47 language tags with a regex#873
azmeuk wants to merge 1 commit intoauthlib:mainfrom
azmeuk:bcp47

Conversation

@azmeuk
Copy link
Copy Markdown
Member

@azmeuk azmeuk commented Mar 23, 2026

I realized that I provided invalid language tags (with underscores), and that caused errors in clients during discovery (that was matrix-authentication-service).

OpenID Connect Core section 5.1

locale string End-User's locale, represented as a BCP47 [RFC5646] language tag. This is typically an ISO 639 Alpha-2 [ISO639] language code in lowercase and an ISO 3166-1 Alpha-2 [ISO3166‑1] country code in uppercase, separated by a dash. For example, en-US or fr-CA. As a compatibility note, some implementations have used an underscore as the separator rather than a dash, for example, en_US; Relying Parties MAY choose to accept this locale syntax as well.

Note that with this PR underscore are rejected by Authlib.
Checklist

  • The commits follow the conventional commits specification.
  • You ran the linters with prek.
  • You wrote unit test to demonstrate the bug you are fixing, or to stress the feature you are bringing.
  • You reached 100% of code coverage on the code you edited, without abusive use of pragma: no cover
  • If this PR is about a new feature, or a behavior change, you have updated the documentation accordingly.
  • You consent that the copyright of your pull request source code belongs to Authlib's author.

@azmeuk azmeuk requested a review from lepture March 23, 2026 11:09
@azmeuk azmeuk changed the title Validate bcp47 language tags with a regex Validate BCP47 language tags with a regex Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant