mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-18 00:09:44 +00:00
LibJS: Disallow U+2212 MINUS SIGN in time zone offset strings
This is a normative change in the ECMA-262 spec. See:
e7f1e5d
This commit is contained in:
parent
517b1a2690
commit
78328ab83c
Notes:
github-actions[bot]
2024-08-14 09:49:17 +00:00
Author: https://github.com/trflynn89
Commit: 78328ab83c
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1065
3 changed files with 11 additions and 10 deletions
|
@ -608,21 +608,21 @@ bool is_time_zone_offset_string(StringView offset_string)
|
|||
// 21.4.1.33.2 ParseTimeZoneOffsetString ( offsetString ), https://tc39.es/ecma262/#sec-parsetimezoneoffsetstring
|
||||
double parse_time_zone_offset_string(StringView offset_string)
|
||||
{
|
||||
// 1. Let parseResult be ParseText(StringToCodePoints(offsetString), UTCOffset).
|
||||
// 1. Let parseResult be ParseText(offsetString, UTCOffset).
|
||||
auto parse_result = Temporal::parse_iso8601(Temporal::Production::TimeZoneNumericUTCOffset, offset_string);
|
||||
|
||||
// 2. Assert: parseResult is not a List of errors.
|
||||
VERIFY(parse_result.has_value());
|
||||
|
||||
// 3. Assert: parseResult contains a TemporalSign Parse Node.
|
||||
// 3. Assert: parseResult contains a ASCIISign Parse Node.
|
||||
VERIFY(parse_result->time_zone_utc_offset_sign.has_value());
|
||||
|
||||
// 4. Let parsedSign be the source text matched by the TemporalSign Parse Node contained within parseResult.
|
||||
// 4. Let parsedSign be the source text matched by the ASCIISign Parse Node contained within parseResult.
|
||||
auto parsed_sign = *parse_result->time_zone_utc_offset_sign;
|
||||
i8 sign { 0 };
|
||||
|
||||
// 5. If parsedSign is the single code point U+002D (HYPHEN-MINUS) or U+2212 (MINUS SIGN), then
|
||||
if (parsed_sign.is_one_of("-"sv, "\xE2\x88\x92"sv)) {
|
||||
// 5. If parsedSign is the single code point U+002D (HYPHEN-MINUS), then
|
||||
if (parsed_sign == "-"sv) {
|
||||
// a. Let sign be -1.
|
||||
sign = -1;
|
||||
}
|
||||
|
|
|
@ -64,11 +64,8 @@ bool ISO8601Parser::parse_sign()
|
|||
{
|
||||
// Sign :
|
||||
// ASCIISign
|
||||
// U+2212
|
||||
StateTransaction transaction { *this };
|
||||
auto success = parse_ascii_sign()
|
||||
|| m_state.lexer.consume_specific("\xE2\x88\x92"sv);
|
||||
if (!success)
|
||||
if (!parse_ascii_sign())
|
||||
return false;
|
||||
m_state.parse_result.sign = transaction.parsed_string_view();
|
||||
transaction.commit();
|
||||
|
|
|
@ -16,9 +16,14 @@ describe("errors", () => {
|
|||
expect(() => {
|
||||
new Temporal.TimeZone("0123456");
|
||||
}).toThrowWithMessage(RangeError, "Invalid time zone name '0123456'");
|
||||
|
||||
expect(() => {
|
||||
new Temporal.TimeZone("23:59:59.9999999999");
|
||||
}).toThrowWithMessage(RangeError, "Invalid time zone name '23:59:59.9999999999'");
|
||||
|
||||
expect(() => {
|
||||
new Temporal.TimeZone("\u221201");
|
||||
}).toThrowWithMessage(RangeError, "Invalid time zone name '\u221201'");
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -58,7 +63,6 @@ describe("normal behavior", () => {
|
|||
const signs = [
|
||||
["+", "+"],
|
||||
["-", "-"],
|
||||
["\u2212", "-"],
|
||||
];
|
||||
const values = [
|
||||
["01", "01:00"],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue