1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:07:35 +00:00

LibJS: Reject structurally invalid Unicode locale extensions

This commit is contained in:
Timothy Flynn 2021-08-28 14:46:36 -04:00 committed by Linus Groh
parent f897c2edb3
commit 94e66f500c
2 changed files with 59 additions and 12 deletions

View file

@ -45,6 +45,29 @@ describe("errors", () => {
Intl.getCanonicalLocales([true]);
}).toThrowWithMessage(TypeError, "true is neither an object nor a string");
});
test("duplicate extension components", () => {
expect(() => {
Intl.getCanonicalLocales("en-u-aa-U-aa");
}).toThrowWithMessage(RangeError, "en-u-aa-U-aa is not a structurally valid language tag");
expect(() => {
Intl.getCanonicalLocales("en-t-aa-T-aa");
}).toThrowWithMessage(RangeError, "en-t-aa-T-aa is not a structurally valid language tag");
expect(() => {
Intl.getCanonicalLocales("en-z-aa-Z-aa");
}).toThrowWithMessage(RangeError, "en-z-aa-Z-aa is not a structurally valid language tag");
});
test("duplicate transformed extension variant subtags", () => {
expect(() => {
Intl.getCanonicalLocales("en-t-en-POSIX-POSIX");
}).toThrowWithMessage(
RangeError,
"en-t-en-POSIX-POSIX is not a structurally valid language tag"
);
});
});
describe("normal behavior", () => {