fix(auth): allow longer reCAPTCHA language tags#9998
Open
KirtiRamchandani wants to merge 1 commit into
Open
Conversation
🦋 Changeset detectedLatest commit: f3aa811 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
There was a problem hiding this comment.
Code Review
This pull request removes the six-character length restriction for browser language tags in the reCAPTCHA loader, allowing for longer tags such as 'en-GB-oxendict'. The change includes an updated validation function, a new test case to verify the fix, and a changeset file. I have no feedback to provide.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
auth.useDeviceLanguage()can setauth.languageCodeto real browser language tags longer than six characters, such asen-GB-oxendict. The reCAPTCHA V2 loader rejects those values asauth/argument-errorbefore loading the script.Root cause
isHostLanguageValid()enforcedhl.length <= 6, which only fits short tags likeenoren-GBand rejects valid longer browser language tags.Solution
Remove the arbitrary six-character limit while preserving the existing alphanumeric/hyphen/whitespace whitelist, and add a regression test that verifies
en-GB-oxendictis accepted and passed through as thehlparameter.Tests run
corepack yarn install --frozen-lockfile --ignore-engines(Node 24 requires ignoring engines; optionalre2native build failed but install completed)corepack yarn --cwd packages/auth build:deps..\..\node_modules\.bin\eslint.cmd -c .eslintrc.js src/platform_browser/recaptcha/recaptcha_loader.ts src/platform_browser/recaptcha/recaptcha_loader.test.ts --ignore-path ../../.gitignorefrompackages/auth.\node_modules\.bin\prettier.cmd --check packages/auth/src/platform_browser/recaptcha/recaptcha_loader.ts packages/auth/src/platform_browser/recaptcha/recaptcha_loader.test.ts .changeset/fix-auth-recaptcha-language-tags.mdcorepack yarn --cwd packages/auth test:browser:unit -- --grep recaptcha_loader(10 tests passed)git diff --checkFixes #8357