Skip to content

bcp47_strict_language_tag accepts repeated variant subtags forbidden by RFC5646 #1677

Closed

Description

@guocn

The bcp47_strict_language_tag validator currently accepts repeated variant subtags, including the invalid example in RFC5646 section2.2.5:

v := validator.New()
fmt.Println(v.Var("de-DE-1901-1901", "bcp47_strict_language_tag")) // <nil>
fmt.Println(v.Var("sl-rozaj-biske-rozaj", "bcp47_strict_language_tag")) // <nil>
fmt.Println(v.Var("sl-ROZAJ-rozaj", "bcp47_strict_language_tag")) // <nil>

Expected: each fails validation. RFC5646 section2.2.5 item5 states “The same variant subtag MUST NOT be used more than once within a language tag” and explicitly identifies de-DE-1901-1901 as invalid: https://www.rfc-editor.org/rfc/rfc5646.html#section-2.2.5.

The current implementation validates each variant in isolation against the parser and registry but never checks whether an earlier variant in the same tag has already used it. The tag has already been lowercased, so case-insensitive duplicate tracking can stay local to that loop.

Reproduced on master a5843c6, Go1.27.3/Linuxamd64. Five negative subtests fail on current source; five controls with distinct variants or repeated private-use subtags pass. This report concerns only duplicate variants; other BCP47 behavior and the non-strict validator are outside its scope. No security impact is claimed.

AI disclosure: OpenAI GPT-6.1 (cpa/gpt-6.1-sol) via OpenClaw performed source analysis, reproduction, patch/test generation and drafted this report. Outputs were locally verified; no human code review is claimed.

Activity

  1. added a commit that references this issue on Oct 29, 2026
    563e738
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions