mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 23:07:35 +00:00
LibJS: Reorder parsing for TimeSpecWithOptionalTimeZoneNotAmbiguous
Because `TimeHour TimeZoneNumericUTCOffsetNotAmbiguous[opt] TimeZoneBracketedAnnotation[opt]` can be a subset of `TimeHourNotValidMonth TimeZone` we would not exhaust the whole input in some cases, which would result in an incorrectly thrown exception.
This commit is contained in:
parent
0866a0cd1e
commit
7ac9900023
1 changed files with 9 additions and 7 deletions
|
@ -1149,6 +1149,15 @@ bool ISO8601Parser::parse_time_spec_with_optional_time_zone_not_ambiguous()
|
|||
// TimeHour : TimeMinute : TimeSecond TimeFraction[opt] TimeZone[opt]
|
||||
// TimeHour TimeMinute TimeSecondNotValidMonth TimeZone[opt]
|
||||
// TimeHour TimeMinute TimeSecond TimeFraction TimeZone[opt]
|
||||
// NOTE: Reverse order here because `TimeHour TimeZoneNumericUTCOffsetNotAmbiguous[opt] TimeZoneBracketedAnnotation[opt]` can
|
||||
// be a subset of `TimeHourNotValidMonth TimeZone`, so we'd not attempt to parse that but may not exhaust the input string.
|
||||
{
|
||||
StateTransaction transaction { *this };
|
||||
if (parse_time_hour_not_valid_month() && parse_time_zone()) {
|
||||
transaction.commit();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
{
|
||||
StateTransaction transaction { *this };
|
||||
if (parse_time_hour()) {
|
||||
|
@ -1194,13 +1203,6 @@ bool ISO8601Parser::parse_time_spec_with_optional_time_zone_not_ambiguous()
|
|||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
StateTransaction transaction { *this };
|
||||
if (parse_time_hour_not_valid_month() && parse_time_zone()) {
|
||||
transaction.commit();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
{
|
||||
StateTransaction transaction { *this };
|
||||
if (parse_time_hour_minute_basic_format_not_ambiguous()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue