-
Notifications
You must be signed in to change notification settings - Fork 17
Validation of 'calendar', 'collation', and 'numberingSystem' options #19
Comments
BCP47 separated "valid" and "well-formed". I'd like us to support "well-formed" here. That means that your example of "en-u-nu-!@-#asdf" will not work because it doesn't match:
but, |
|
I believe so. @littledan @srl295 ? |
My intention here is that we should not cap the values that are well-formed and potentially supported by some language tag parsing code just because our APIs don't support a certain value. For example, maybe at some point UTS will add |
(Note: Updated the issue description to note a possible problem with the third choice.) |
I'm not sure if ICU contains an API for this validation, cc @jungshik . The question here is closely related to that in tc39/ecma402#175 (comment) though we may decide to answer it differently if Intl formatters are validating and With the patch in For that reason, option 2 seems good to me. But, if we go with that, maybe we want to perform similar validation in existing Intl constructors. Or should we continue to omit the validation for compatibility? Seems like we should discuss this issue in the Intl VC call. |
The following functions should probably fit our needs:
Plus |
We discussed this issue in the Intl meeting, and the group consensus was to validate just the grammar, as @anba's patch ended up doing. |
Fixed by #23. |
The 'calendar', 'collation', and 'numberingSystem' options need to be validated, otherwise we could end up with invalid language tags, for example
new Intl.Locale("en", {numberingSystem: "!@-#asdf"}).toString()
should not returnen-u-nu-!@-#asdf
.Three possible choices:
(3*8alphanum) *("-" (3*8alphanum))
(in RFC 5646's ABNF) resp. thetype
production per UTS35.[(3*8alphanum) *("-" (3*8alphanum))]
sequence, throw a RangeError exception.- Or change the (currently incorrect) assertion in ApplyUnicodeExtensionToTag:
1. Assert: ! IsStructurallyValidLanguageTag(locale) is true.1. If ! IsStructurallyValidLanguageTag(locale) is false, throw a RangeError.
(See Edit 1 and Edit 2 below.)
Edit 1:
The third proposal (calling IsStructurallyValidLanguageTag in ApplyUnicodeExtensionToTag for validation) is probably not the right choice, because it may let
new Intl.Locale("en", {numberingSystem: "latn-ca-gregory"})
slip through.Edit 2:
Yup, just tested that this'll be a non-starter:
The text was updated successfully, but these errors were encountered: