Skip to content

fix: reject duplicate extlangs in strict BCP47 tags - #1705

Open
waw666waw666 wants to merge 1 commit into
go-playground:masterfrom
waw666waw666:fix/bcp47-duplicate-extlang
Open

waw666waw666 wants to merge 1 commit into
go-playground:masterfrom
waw666waw666:fix/bcp47-duplicate-extlang

Conversation

@waw666waw666

Copy link
Copy Markdown

RFC 5646 section 2.2.2 defines extlang as 3ALPHA *("-" 3ALPHA), each at most once, but isBCP47StrictLanguageTag checked every extlang only for registry membership and the required base prefix, never for whether it had already occurred. Tags such as zh-cmn-cmn, zh-yue-yue and ar-arb-arb were accepted. This is the same class of gap as the duplicate variants rejected in #1678, in the same function.

Fix: track seen extlangs in the existing loop and reject a repeat. The input is already lowercased, so mixed-case repeats are rejected too. The non-strict validator is unchanged, as in #1678.

Tests: new TestBCP47StrictDuplicateExtlangs with 4 duplicate cases and 4 valid controls. All 4 duplicates fail on the old code and all 8 subtests pass with the fix; the full suite (go test ./..., 28 packages) passes with no new failures, and go vet is clean.

AI-assisted contribution: investigation, implementation, tests and this description were produced with AI assistance (Muse). Prepared by an AI agent on behalf of the contributor.

Co-Authored-By: Muse <noreply@meta.com>
@waw666waw666
waw666waw666 requested a review from a team as a code owner November 27, 2026 04:44
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 72.675% (+0.007%) from 72.668% — waw666waw666:fix/bcp47-duplicate-extlang into go-playground:master

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.

2 participants