Skip to content

fix(auth): allow longer reCAPTCHA language tags#9998

Open
KirtiRamchandani wants to merge 1 commit into
firebase:mainfrom
KirtiRamchandani:fix/recaptcha-long-language-tags
Open

fix(auth): allow longer reCAPTCHA language tags#9998
KirtiRamchandani wants to merge 1 commit into
firebase:mainfrom
KirtiRamchandani:fix/recaptcha-long-language-tags

Conversation

@KirtiRamchandani
Copy link
Copy Markdown

Problem

auth.useDeviceLanguage() can set auth.languageCode to real browser language tags longer than six characters, such as en-GB-oxendict. The reCAPTCHA V2 loader rejects those values as auth/argument-error before loading the script.

Root cause

isHostLanguageValid() enforced hl.length <= 6, which only fits short tags like en or en-GB and 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-oxendict is accepted and passed through as the hl parameter.

Tests run

  • corepack yarn install --frozen-lockfile --ignore-engines (Node 24 requires ignoring engines; optional re2 native 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 ../../.gitignore from packages/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.md
  • corepack yarn --cwd packages/auth test:browser:unit -- --grep recaptcha_loader (10 tests passed)
  • git diff --check

Fixes #8357

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 25, 2026

🦋 Changeset detected

Latest commit: f3aa811

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@firebase/auth Patch
@firebase/auth-compat Patch
firebase Patch

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

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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.

isHostLanguageValid() in auth's recaptcha loader incorrectly determines long language codes to be invalid

1 participant