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

LibJS: Check if input was exhausted after parsing UTC offset fraction

Previously parse_time_zone_numeric_utc_offset_syntax() would return true
to indicate success when parsing a string with an invalid number of
digits in the fractional seconds part (e.g. 23:59:59.9999999999).
We need to check if the lexer has any characters remaining, and return
false if that's the case.
This commit is contained in:
Linus Groh 2022-01-11 20:11:59 +01:00
parent de07312cc7
commit f1276144ba
2 changed files with 13 additions and 1 deletions

View file

@ -10,6 +10,16 @@ describe("errors", () => {
new Temporal.TimeZone("foo");
}).toThrowWithMessage(RangeError, "Invalid time zone name 'foo'");
});
test("Invalid numeric UTC offset", () => {
// FIXME: Error message should probably say '...name or UTC offset ...' :^)
expect(() => {
new Temporal.TimeZone("0123456");
}).toThrowWithMessage(RangeError, "Invalid time zone name '0123456'");
expect(() => {
new Temporal.TimeZone("23:59:59.9999999999");
}).toThrowWithMessage(RangeError, "Invalid time zone name '23:59:59.9999999999'");
});
});
describe("normal behavior", () => {