Repository navigation
fix: reject duplicate extlangs in strict BCP47 tags - #1705
Open
waw666waw666 wants to merge 1 commit into
Open
waw666waw666 wants to merge 1 commit into
waw666waw666 wants to merge 1 commit into
Conversation
Co-Authored-By: Muse <noreply@meta.com>
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.
RFC 5646 section 2.2.2 defines extlang as
3ALPHA *("-" 3ALPHA), each at most once, butisBCP47StrictLanguageTagchecked every extlang only for registry membership and the required base prefix, never for whether it had already occurred. Tags such aszh-cmn-cmn,zh-yue-yueandar-arb-arbwere 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
TestBCP47StrictDuplicateExtlangswith 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, andgo vetis 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.