mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:37:37 +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
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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue