[Temporal] Fix timezone and calendar parsing issue

Need to reset tzi_xxx and calendar_xxx in parser state if the
post-condition of CalendarName and TimeZoneIdentifier is not met.

Bug: v8:11544
Change-Id: If2df6c8fc8cf2418ddd5443abab02066d423a0c3
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3893554
Commit-Queue: Frank Tang <ftang@chromium.org>
Reviewed-by: Shu-yu Guo <syg@chromium.org>
Cr-Commit-Position: refs/heads/main@{#83236}
This commit is contained in:
Frank Tang 2022-09-13 13:27:04 -07:00 committed by V8 LUCI CQ
parent 4444874cdf
commit adc30b07c0
2 changed files with 9 additions and 1 deletions

View File

@ -707,6 +707,10 @@ int32_t ScanTimeZoneBracketedAnnotation(base::Vector<Char> str, int32_t s,
int32_t len = ScanTimeZoneIdentifier(str, cur, r);
cur += len;
if (len == 0 || str.length() < (cur + 1) || (str[cur] != ']')) {
// Only ScanTimeZoneBracketedAnnotation know the post condition of
// TimeZoneIdentifier is not matched so we need to reset here.
r->tzi_name_start = 0;
r->tzi_name_length = 0;
return 0;
}
cur++;
@ -878,6 +882,10 @@ int32_t ScanCalendar(base::Vector<Char> str, int32_t s,
int32_t len = ScanCalendarName(str, cur, r);
if (len == 0) return 0;
if ((str.length() < (cur + len + 1)) || (str[cur + len] != ']')) {
// Only ScanCalendar know the post condition of CalendarName is not met and
// need to reset here.
r->calendar_name_start = 0;
r->calendar_name_length = 0;
return 0;
}
return 6 + len + 1;

View File

@ -537,7 +537,6 @@
'staging/Temporal/Duration/old/toString': [FAIL],
'staging/Temporal/Duration/old/total': [FAIL],
'staging/Temporal/Regex/old/plaintime': [FAIL],
'staging/Temporal/Regex/old/timezone': [FAIL],
'staging/Temporal/TimeZone/old/subminute-offset': [FAIL],
'staging/Temporal/ZonedDateTime/old/construction-and-properties': [FAIL],
'staging/Temporal/ZonedDateTime/old/dst-math': [FAIL],
@ -797,6 +796,7 @@
'staging/Temporal/Duration/old/subtract': [FAIL],
'staging/Temporal/Instant/old/toZonedDateTime': [FAIL],
'staging/Temporal/Instant/old/toZonedDateTimeISO': [FAIL],
'staging/Temporal/Regex/old/timezone': [FAIL],
'staging/Temporal/TimeZone/old/dst-change': [FAIL],
'staging/Temporal/TimeZone/old/getInstantFor': [FAIL],
'staging/Temporal/TimeZone/old/getInstantFor-disambiguation': [FAIL],