Commit 2fc37ae5 authored by Frank Tang's avatar Frank Tang Committed by V8 LUCI CQ

[Temporal] Syntax error if DateExtendedYear is -000000

Sync to PR2036
https://github.com/tc39/proposal-temporal/pull/2036

Treat -000000 in DateExtendedYear as syntax error

Bug: v8:11544
Change-Id: I8cf7a506e85ad2b74d572142d646f3f98cd8bffa
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3633620
Commit-Queue: Frank Tang <ftang@chromium.org>
Reviewed-by: 's avatarShu-yu Guo <syg@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80705}
parent caa55eca
......@@ -284,6 +284,10 @@ int32_t ScanDateExtendedYear(base::Vector<Char> str, int32_t s, int32_t* out) {
*out = sign * (ToInt(str[s + 1]) * 100000 + ToInt(str[s + 2]) * 10000 +
ToInt(str[s + 3]) * 1000 + ToInt(str[s + 4]) * 100 +
ToInt(str[s + 5]) * 10 + ToInt(str[s + 6]));
// In the end of #sec-temporal-iso8601grammar
// It is a Syntax Error if DateExtendedYear is "-000000" or "−000000"
// (U+2212 MINUS SIGN followed by 000000).
if (sign == -1 && *out == 0) return 0;
return 7;
}
return 0;
......
......@@ -176,10 +176,6 @@ TEST(TemporalDateStringSuccess) {
VerifyParseTemporalDateStringSuccess(isolate, "+0000011231", 1, 12, 31, "");
VerifyParseTemporalDateStringSuccess(isolate, "+0000000101", 0, 1, 1, "");
VerifyParseTemporalDateStringSuccess(isolate, "+0000000101", 0, 1, 1, "");
VerifyParseTemporalDateStringSuccess(isolate, "-0000000101", 0, 1, 1, "");
VerifyParseTemporalDateStringSuccess(isolate, "\u22120000000101", 0, 1, 1,
"");
VerifyParseTemporalDateStringSuccess(isolate, "-0000000101", 0, 1, 1, "");
VerifyParseTemporalDateStringSuccess(isolate, "+654321-11-03", 654321, 11, 3,
"");
VerifyParseTemporalDateStringSuccess(isolate, "+999999-12-31", 999999, 12, 31,
......@@ -410,6 +406,10 @@ TEST(TemporalDateStringSuccess) {
VERIFY_PARSE_FAIL(R, "0002021-09-03"); \
VERIFY_PARSE_FAIL(R, "-0002021-09-03"); \
\
/* It is a Syntax Error if DateExtendedYear is "-000000" */ \
VERIFY_PARSE_FAIL(R, "-000000-09-03"); \
VERIFY_PARSE_FAIL(R, "\u2212000000-09-03"); \
\
/* single digit month */ \
VERIFY_PARSE_FAIL(R, "1900-9-03"); \
VERIFY_PARSE_FAIL(R, "1900903"); \
......@@ -553,6 +553,9 @@ TEST(TemporalDateStringIllegal) {
VERIFY_PARSE_FAIL(TemporalDateString, "-20210304");
VERIFY_PARSE_FAIL(TemporalDateString, "\u221220210304");
VERIFY_PARSE_FAIL(TemporalDateString, "210304");
// It is a Syntax Error if DateExtendedYear is "-000000"
VERIFY_PARSE_FAIL(TemporalDateString, "-0000000304");
VERIFY_PARSE_FAIL(TemporalDateString, "\u22120000000304");
}
void VerifyTemporalTimeStringTimeUndefined(Isolate* isolate, const char* str) {
......@@ -577,9 +580,6 @@ TEST(TemporalTimeStringSuccess) {
VerifyTemporalTimeStringTimeUndefined(isolate, "+0000011231");
VerifyTemporalTimeStringTimeUndefined(isolate, "+0000000101");
VerifyTemporalTimeStringTimeUndefined(isolate, "+0000000101");
VerifyTemporalTimeStringTimeUndefined(isolate, "-0000000101");
VerifyTemporalTimeStringTimeUndefined(isolate, "\u22120000000101");
VerifyTemporalTimeStringTimeUndefined(isolate, "-0000000101");
VerifyTemporalTimeStringTimeUndefined(isolate, "+654321-11-03");
VerifyTemporalTimeStringTimeUndefined(isolate, "+999999-12-31");
VerifyTemporalTimeStringTimeUndefined(isolate, "-654321-11-03");
......@@ -871,12 +871,6 @@ TEST(TemporalTimeStringIllegal) {
kUndefined, kUndefined, kUndefined, ""); \
VerifyParse##R##Success(isolate, "+0000000101", 0, 1, 1, kUndefined, \
kUndefined, kUndefined, kUndefined, ""); \
VerifyParse##R##Success(isolate, "-0000000101", 0, 1, 1, kUndefined, \
kUndefined, kUndefined, kUndefined, ""); \
VerifyParse##R##Success(isolate, "\u22120000000101", 0, 1, 1, kUndefined, \
kUndefined, kUndefined, kUndefined, ""); \
VerifyParse##R##Success(isolate, "-0000000101", 0, 1, 1, kUndefined, \
kUndefined, kUndefined, kUndefined, ""); \
VerifyParse##R##Success(isolate, "+654321-11-03", 654321, 11, 3, \
kUndefined, kUndefined, kUndefined, kUndefined, \
""); \
......@@ -1136,6 +1130,9 @@ TEST(TemporalDateTimeStringIllegal) {
VERIFY_PARSE_FAIL(TemporalDateTimeString, "-20210304");
VERIFY_PARSE_FAIL(TemporalDateTimeString, "\u221220210304");
VERIFY_PARSE_FAIL(TemporalDateTimeString, "210304");
// It is a Syntax Error if DateExtendedYear is "-000000"
VERIFY_PARSE_FAIL(TemporalDateTimeString, "-0000000304");
VERIFY_PARSE_FAIL(TemporalDateTimeString, "\u22120000000304");
}
TEST(TemporalYearMonthStringSuccess) {
......@@ -1180,12 +1177,6 @@ TEST(TemporalYearMonthStringSuccess) {
"");
VerifyParseTemporalYearMonthStringSuccess(isolate, "+0000000101", 0, 1, 1,
"");
VerifyParseTemporalYearMonthStringSuccess(isolate, "-0000000101", 0, 1, 1,
"");
VerifyParseTemporalYearMonthStringSuccess(isolate, "\u22120000000101", 0, 1,
1, "");
VerifyParseTemporalYearMonthStringSuccess(isolate, "-0000000101", 0, 1, 1,
"");
VerifyParseTemporalYearMonthStringSuccess(isolate, "+654321-11-03", 654321,
11, 3, "");
VerifyParseTemporalYearMonthStringSuccess(isolate, "+999999-12-31", 999999,
......@@ -1408,6 +1399,11 @@ TEST(TemporalYearMonthStringIllegal) {
VERIFY_PARSE_FAIL(TemporalYearMonthString, "+1");
VERIFY_PARSE_FAIL(TemporalYearMonthString, "-1");
VERIFY_PARSE_FAIL(TemporalYearMonthString, "\u22121");
// It is a Syntax Error if DateExtendedYear is "-000000"
VERIFY_PARSE_FAIL(TemporalYearMonthString, "-000000");
VERIFY_PARSE_FAIL(TemporalYearMonthString, "\u2212000000");
VERIFY_PARSE_FAIL(TemporalYearMonthString, "-00000001");
VERIFY_PARSE_FAIL(TemporalYearMonthString, "\u221200000001");
}
TEST(TemporalMonthDayStringSuccess) {
......@@ -1447,10 +1443,6 @@ TEST(TemporalMonthDayStringSuccess) {
"");
VerifyParseTemporalMonthDayStringSuccess(isolate, "+0000000101", 0, 1, 1, "");
VerifyParseTemporalMonthDayStringSuccess(isolate, "+0000000101", 0, 1, 1, "");
VerifyParseTemporalMonthDayStringSuccess(isolate, "-0000000101", 0, 1, 1, "");
VerifyParseTemporalMonthDayStringSuccess(isolate, "\u22120000000101", 0, 1, 1,
"");
VerifyParseTemporalMonthDayStringSuccess(isolate, "-0000000101", 0, 1, 1, "");
VerifyParseTemporalMonthDayStringSuccess(isolate, "+654321-11-03", 654321, 11,
3, "");
VerifyParseTemporalMonthDayStringSuccess(isolate, "+999999-12-31", 999999, 12,
......@@ -1806,6 +1798,10 @@ TEST(TemporalInstantStringIllegal) {
// fraction too long
VERIFY_PARSE_FAIL(TemporalInstantString, "20211109-073401.0000000000");
VERIFY_PARSE_FAIL(TemporalInstantString, "20211109+073401,9876543219");
// It is a Syntax Error if DateExtendedYear is "-000000"
VERIFY_PARSE_FAIL(TemporalInstantString, "-0000001109+073401,9876543219");
VERIFY_PARSE_FAIL(TemporalInstantString,
"\u22120000001109+073401,9876543219");
}
#define IMPL_ZONED_DATE_TIME_STRING_SUCCESS(R) \
......@@ -1872,6 +1868,8 @@ TEST(TemporalZonedDateTimeStringSuccess) {
VERIFY_PARSE_FAIL(R, "2021-03-04t23:59:20.1234[+123456.9876543210]"); \
VERIFY_PARSE_FAIL(R, "2021-03-04t23:59:20.1234[+123456.]"); \
VERIFY_PARSE_FAIL(R, "2021-03-04t23:59:20.1234[+123456,]"); \
VERIFY_PARSE_FAIL(R, "-000000-03-04t23:59:20.1234[+123456,]"); \
VERIFY_PARSE_FAIL(R, "\u2212000000-03-04t23:59:20.1234[+123456,]"); \
} while (false)
TEST(TemporalZonedDateTimeStringIllegal) {
......@@ -1898,6 +1896,9 @@ TEST(TemporalRelativeToStringIllegal) {
VERIFY_PARSE_FAIL(TemporalRelativeToString, "-20210304");
VERIFY_PARSE_FAIL(TemporalRelativeToString, "\u221220210304");
VERIFY_PARSE_FAIL(TemporalRelativeToString, "210304");
// It is a Syntax Error if DateExtendedYear is "-000000"
VERIFY_PARSE_FAIL(TemporalRelativeToString, "-0000000304");
VERIFY_PARSE_FAIL(TemporalRelativeToString, "\u22120000000304");
}
TEST(TemporalCalendarStringSuccess) {
......@@ -1942,6 +1943,9 @@ TEST(TemporalCalendarStringIllegal) {
VERIFY_PARSE_FAIL(TemporalCalendarString, "20210304[u-ca=ab]");
VERIFY_PARSE_FAIL(TemporalCalendarString, "20210304[u-ca=abcdef-ab]");
VERIFY_PARSE_FAIL(TemporalCalendarString, "20210304[u-ca=abcdefghijkl]");
// It is a Syntax Error if DateExtendedYear is "-000000"
VERIFY_PARSE_FAIL(TemporalCalendarString, "-0000000304[u-ca=abcdef-ab]");
VERIFY_PARSE_FAIL(TemporalCalendarString, "\u22120000000304[u-ca=abcdef-ab]");
}
void CheckDuration(const ParsedISO8601Duration& actual, int64_t sign,
......
......@@ -1800,23 +1800,8 @@
'intl402/Temporal/ZonedDateTime/prototype/equals/timezone-string-datetime': [FAIL],
'intl402/Temporal/ZonedDateTime/prototype/since/timezone-string-datetime': [FAIL],
'intl402/Temporal/ZonedDateTime/prototype/until/timezone-string-datetime': [FAIL],
'intl402/Temporal/Calendar/prototype/eraYear/year-zero': [FAIL],
'intl402/Temporal/Calendar/prototype/era/year-zero': [FAIL],
'intl402/Temporal/PlainYearMonth/from/argument-object': [FAIL],
'built-ins/Temporal/Calendar/prototype/dateAdd/year-zero': [FAIL],
'built-ins/Temporal/Calendar/prototype/dateUntil/year-zero': [FAIL],
'built-ins/Temporal/Calendar/prototype/dayOfWeek/year-zero': [FAIL],
'built-ins/Temporal/Calendar/prototype/dayOfYear/year-zero': [FAIL],
'built-ins/Temporal/Calendar/prototype/daysInMonth/year-zero': [FAIL],
'built-ins/Temporal/Calendar/prototype/daysInWeek/year-zero': [FAIL],
'built-ins/Temporal/Calendar/prototype/daysInYear/year-zero': [FAIL],
'built-ins/Temporal/Calendar/prototype/day/year-zero': [FAIL],
'built-ins/Temporal/Calendar/prototype/inLeapYear/year-zero': [FAIL],
'built-ins/Temporal/Calendar/prototype/monthCode/year-zero': [FAIL],
'built-ins/Temporal/Calendar/prototype/monthsInYear/year-zero': [FAIL],
'built-ins/Temporal/Calendar/prototype/month/year-zero': [FAIL],
'built-ins/Temporal/Calendar/prototype/weekOfYear/year-zero': [FAIL],
'built-ins/Temporal/Calendar/prototype/year/year-zero': [FAIL],
'built-ins/Temporal/Duration/compare/argument-string-fractional-units-rounding-mode': [FAIL],
'built-ins/Temporal/Duration/compare/calendar-possibly-required': [FAIL],
'built-ins/Temporal/Duration/compare/year-zero': [FAIL],
......@@ -1831,7 +1816,6 @@
'built-ins/Temporal/Duration/prototype/total/year-zero': [FAIL],
'built-ins/Temporal/Duration/prototype/with/copy-properties-not-undefined': [FAIL],
'built-ins/Temporal/Instant/compare/year-zero': [FAIL],
'built-ins/Temporal/Instant/from/year-zero': [FAIL],
'built-ins/Temporal/Instant/prototype/add/argument-string-fractional-units-rounding-mode': [FAIL],
'built-ins/Temporal/Instant/prototype/equals/year-zero': [FAIL],
'built-ins/Temporal/Instant/prototype/since/largestunit-smallestunit-mismatch': [FAIL],
......@@ -1840,7 +1824,6 @@
'built-ins/Temporal/Instant/prototype/until/largestunit-smallestunit-mismatch': [FAIL],
'built-ins/Temporal/Instant/prototype/until/year-zero': [FAIL],
'built-ins/Temporal/PlainDate/compare/year-zero': [FAIL],
'built-ins/Temporal/PlainDate/from/year-zero': [FAIL],
'built-ins/Temporal/PlainDate/prototype/add/argument-invalid-duration': [FAIL],
'built-ins/Temporal/PlainDate/prototype/add/argument-missing-properties': [FAIL],
'built-ins/Temporal/PlainDate/prototype/add/argument-singular-units': [FAIL],
......@@ -1888,7 +1871,6 @@
'built-ins/Temporal/PlainDate/prototype/until/year-zero': [FAIL],
'built-ins/Temporal/PlainDate/prototype/with/copy-properties-not-undefined': [FAIL],
'built-ins/Temporal/PlainDateTime/compare/year-zero': [FAIL],
'built-ins/Temporal/PlainDateTime/from/year-zero': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/add/argument-string-fractional-units-rounding-mode': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/equals/year-zero': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/since/largestunit-smallestunit-mismatch': [FAIL],
......@@ -1903,7 +1885,6 @@
'built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-string-time-designator-required-for-disambiguation': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-string-with-time-designator': [FAIL],
'built-ins/Temporal/PlainDateTime/prototype/withPlainTime/year-zero': [FAIL],
'built-ins/Temporal/PlainMonthDay/from/year-zero': [FAIL],
'built-ins/Temporal/PlainMonthDay/prototype/equals/year-zero': [FAIL],
'built-ins/Temporal/PlainMonthDay/prototype/with/copy-properties-not-undefined': [FAIL],
'built-ins/Temporal/PlainTime/compare/argument-cast': [FAIL],
......@@ -1916,7 +1897,6 @@
'built-ins/Temporal/PlainTime/from/argument-string-no-implicit-midnight': [FAIL],
'built-ins/Temporal/PlainTime/from/argument-string-time-designator-required-for-disambiguation': [FAIL],
'built-ins/Temporal/PlainTime/from/argument-string-with-time-designator': [FAIL],
'built-ins/Temporal/PlainTime/from/year-zero': [FAIL],
'built-ins/Temporal/PlainTime/prototype/add/argument-duration': [FAIL],
'built-ins/Temporal/PlainTime/prototype/add/argument-higher-units': [FAIL],
'built-ins/Temporal/PlainTime/prototype/add/argument-object': [FAIL],
......@@ -2007,7 +1987,6 @@
'built-ins/Temporal/PlainYearMonth/compare/compare-calendar': [FAIL],
'built-ins/Temporal/PlainYearMonth/compare/compare-reference-day': [FAIL],
'built-ins/Temporal/PlainYearMonth/compare/year-zero': [FAIL],
'built-ins/Temporal/PlainYearMonth/from/year-zero': [FAIL],
'built-ins/Temporal/PlainYearMonth/prototype/add/argument-duration-object': [FAIL],
'built-ins/Temporal/PlainYearMonth/prototype/add/argument-lower-units': [FAIL],
'built-ins/Temporal/PlainYearMonth/prototype/add/argument-object': [FAIL],
......@@ -2062,9 +2041,6 @@
'built-ins/Temporal/PlainYearMonth/prototype/with/basic': [FAIL],
'built-ins/Temporal/PlainYearMonth/prototype/with/copy-properties-not-undefined': [FAIL],
'built-ins/Temporal/PlainYearMonth/prototype/with/options-wrong-type': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getInstantFor/year-zero': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/year-zero': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/year-zero': [FAIL],
'built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-offset-not-agreeing-with-timezone': [FAIL],
'built-ins/Temporal/ZonedDateTime/compare/year-zero': [FAIL],
'built-ins/Temporal/ZonedDateTime/from/argument-propertybag-offset-not-agreeing-with-timezone': [FAIL],
......@@ -2084,7 +2060,6 @@
'built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-no-implicit-midnight': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-time-designator-required-for-disambiguation': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-with-time-designator': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/year-zero': [FAIL],
'built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-invalid': [FAIL],
'built-ins/Temporal/Duration/compare/twenty-five-hour-day': [FAIL],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment