mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibJS: Fix fraction substring range in parse_temporal_time_zone_string()
Two issues: - The intended range was 9 characters starting from index 1. Since the second argument to String::substring() is the length, 10 is potentially reading further than the string's length (when only providing one fraction digit), causing an assertion failure crash. - The spec's intention to skip the decimal separator by starting at index 1 is incorrect, no decimal separator is present in the result of parsing TimeZoneUTCOffsetFractionalPart. I filed a spec fix for this, see: https://github.com/tc39/proposal-temporal/pull/1999
This commit is contained in:
parent
027e4bd439
commit
392f5bfebd
Notes:
sideshowbarker
2024-07-17 21:02:02 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/392f5bfebd0 Pull-request: https://github.com/SerenityOS/serenity/pull/11840 Reviewed-by: https://github.com/IdanHo
2 changed files with 7 additions and 7 deletions
|
@ -1663,7 +1663,9 @@ ThrowCompletionOr<TemporalTimeZone> parse_temporal_time_zone_string(GlobalObject
|
|||
auto fraction = String::formatted("{}000000000", *fraction_part);
|
||||
// ii. Let nanoseconds be the String value equal to the substring of fraction from 1 to 10.
|
||||
// iii. Set nanoseconds to ! ToIntegerOrInfinity(nanoseconds).
|
||||
nanoseconds = *fraction.substring(1, 10).to_int<i32>();
|
||||
// FIXME: 1-10 is wrong and should be 0-9; the decimal separator is no longer present in the parsed string.
|
||||
// See: https://github.com/tc39/proposal-temporal/pull/1999
|
||||
nanoseconds = *fraction.substring(0, 9).to_int<i32>();
|
||||
}
|
||||
// h. Else,
|
||||
else {
|
||||
|
|
|
@ -30,14 +30,12 @@ describe("normal behavior", () => {
|
|||
["1970-01-01T00:00:00.000000000+01:00:00", "+01:00"],
|
||||
["1970-01-01+12:34", "+12:34"],
|
||||
["1970-01-01+12:34:56", "+12:34:56"],
|
||||
// FIXME: These currently crash :^(
|
||||
// ["1970-01-01+12:34:56.789", "+12:34:56.789"],
|
||||
// ["1970-01-01+12:34:56.789[-01:00]", "+12:34:56.789"],
|
||||
["1970-01-01+12:34:56.789", "+12:34:56.789"],
|
||||
["1970-01-01+12:34:56.789[-01:00]", "+12:34:56.789"],
|
||||
["1970-01-01-12:34", "-12:34"],
|
||||
["1970-01-01-12:34:56", "-12:34:56"],
|
||||
// FIXME: These currently crash :^(
|
||||
// ["1970-01-01-12:34:56.789", "-12:34:56.789"],
|
||||
// ["1970-01-01-12:34:56.789[+01:00]", "-12:34:56.789"],
|
||||
["1970-01-01-12:34:56.789", "-12:34:56.789"],
|
||||
["1970-01-01-12:34:56.789[+01:00]", "-12:34:56.789"],
|
||||
];
|
||||
for (const [arg, expected] of values) {
|
||||
expect(Temporal.TimeZone.from(arg).id).toBe(expected);
|
||||
|
|
Loading…
Reference in a new issue