mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:47:45 +00:00
LibJS: Disallow calendar display names which contain an underscore
This is a normative change in the Intl spec. See:
2703d06
This commit is contained in:
parent
7c41e6058a
commit
f8e7701cf3
2 changed files with 10 additions and 2 deletions
|
@ -150,8 +150,12 @@ ThrowCompletionOr<Value> canonical_code_for_display_names(GlobalObject& global_o
|
||||||
if (!Unicode::is_type_identifier(code))
|
if (!Unicode::is_type_identifier(code))
|
||||||
return vm.throw_completion<RangeError>(global_object, ErrorType::OptionIsNotValidValue, code, "calendar"sv);
|
return vm.throw_completion<RangeError>(global_object, ErrorType::OptionIsNotValidValue, code, "calendar"sv);
|
||||||
|
|
||||||
// b. Let code be the result of mapping code to lower case as described in 6.1.
|
// b. If code uses any of the backwards compatibility syntax described in Unicode Technical Standard #35 LDML § 3.3 BCP 47 Conformance, throw a RangeError exception.
|
||||||
// c. Return code.
|
if (code.contains('_'))
|
||||||
|
return vm.throw_completion<RangeError>(global_object, ErrorType::OptionIsNotValidValue, code, "calendar"sv);
|
||||||
|
|
||||||
|
// c. Let code be the result of mapping code to lower case as described in 6.1.
|
||||||
|
// d. Return code.
|
||||||
return js_string(vm, code.to_lowercase_string());
|
return js_string(vm, code.to_lowercase_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,10 @@ describe("errors", () => {
|
||||||
expect(() => {
|
expect(() => {
|
||||||
new Intl.DisplayNames("en", { type: "calendar" }).of("hello!");
|
new Intl.DisplayNames("en", { type: "calendar" }).of("hello!");
|
||||||
}).toThrowWithMessage(RangeError, "hello! is not a valid value for option calendar");
|
}).toThrowWithMessage(RangeError, "hello! is not a valid value for option calendar");
|
||||||
|
|
||||||
|
expect(() => {
|
||||||
|
new Intl.DisplayNames("en", { type: "calendar" }).of("abc_def");
|
||||||
|
}).toThrowWithMessage(RangeError, "abc_def is not a valid value for option calendar");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("invalid dateTimeField", () => {
|
test("invalid dateTimeField", () => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue