Skip to content

Parsing of extensions: too generous? #1

Description

@rwalkerands

Hi, I've been using the app-subtags web page to develop my understanding of BCP 47, and it has been very helpful; thank you.

Today I've been looking at extension subtags, and it seems that either (a) I've misunderstood BCP 47, or (b) app-subtags is "too generous" in accepting some uses of extensions.

The removeExtensions() function seems to assume that there is at most one extension, and this leads to some problems with the parsing.

So app-subtags accepts the following tag as well-formed, when, I think, based on RFC 5646, section 2.2.6, it should reject it:

  • tlh-t-u-foo : "Each singleton MUST be followed by at least one extension subtag" (RFC 5646, section 2.2.6, point 6). This tag is not "well-formed" according to the definition of well-formedness in section 2.2.9, since the tag does not conform to the ABNF in section 2.1. app-subtags incorrectly parses this as "the extension t-u-foo".

The following are well-formed, since they conform to the ABNF, but there is an opportunity for app-subtags to be "more helpful" in pointing out errors:

  • en-t-aaa-a-bbb : "The singleton MUST be one allocated to a registration authority via the mechanism described in Section 3.7 ..." (RFC 5646, section 2.2.6, point 2). The app-subtags code does already check that the singleton t is valid, but then doesn't "notice" that a- is the beginning of another extension, and check the singleton a.
  • en-t-bbb-t-ccc : "Each singleton subtag MUST appear at most one time in each tag (other than as a private use subtag)" (RFC 5646, section 2.2.6, point 3). Ditto, and as you parse, you have to keep track of which singletons you've seen, and make sure there aren't duplicates.

Activity

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions