Changeset 255452 in webkit


Ignore:
Timestamp:
Jan 30, 2020 1:27:11 PM (4 years ago)
Author:
Alexey Shvayka
Message:

Incomplete braced quantifiers should be banned in Unicode patterns only
https://bugs.webkit.org/show_bug.cgi?id=206776

Reviewed by Darin Adler.

JSTests:

Although the change does not affect Unicode property escapes, a few
test/built-ins/RegExp/property-escapes/non-existent-property-value*.js files
are now passing because they had
p or
P instead of CharacterClassEscape.

  • test262/expectations.yaml: Mark 18 test cases as passing.

Source/JavaScriptCore:

This change adds SyntaxError for Unicode patterns, aligning JSC with
V8 and SpiderMonkey, and also capitalizes "Unicode" in error messages.

Grammar: https://tc39.es/ecma262/#prod-annexB-Term
(/u flag precludes the use of ExtendedAtom and thus InvalidBracedQuantifier)

  • yarr/YarrErrorCode.cpp:

(JSC::Yarr::errorMessage):
(JSC::Yarr::errorToThrow):

  • yarr/YarrErrorCode.h:
  • yarr/YarrParser.h:

(JSC::Yarr::Parser::parseTokens):

LayoutTests:

An error message test is added for this change and for webkit.org/b/206768.
Other tests are adjusted for capitalized "Unicode" in error messages.

  • js/regexp-named-capture-groups-expected.txt:
  • js/regexp-unicode-expected.txt:
  • js/regress-158080-expected.txt:
  • js/script-tests/regexp-named-capture-groups.js:
  • js/script-tests/regexp-unicode.js:
Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r255440 r255452  
     12020-01-30  Alexey Shvayka  <shvaikalesh@gmail.com>
     2
     3        Incomplete braced quantifiers should be banned in Unicode patterns only
     4        https://bugs.webkit.org/show_bug.cgi?id=206776
     5
     6        Reviewed by Darin Adler.
     7
     8        Although the change does not affect Unicode property escapes, a few
     9        test/built-ins/RegExp/property-escapes/non-existent-property-value*.js files
     10        are now passing because they had \\p or \\P instead of CharacterClassEscape.
     11
     12        * test262/expectations.yaml: Mark 18 test cases as passing.
     13
    1142020-01-30  Keith Miller  <keith_miller@apple.com>
    215
     
    86992020-01-26  Alexey Shvayka  <shvaikalesh@gmail.com>
    87100
    88         Invalid ranges in character classes should be banned in unicode patterns
     101        Invalid ranges in character classes should be banned in Unicode patterns only
    89102        https://bugs.webkit.org/show_bug.cgi?id=206768
    90103
  • trunk/JSTests/test262/expectations.yaml

    r255134 r255452  
    1212  default: 'Test262Error: Expected SameValue(«», «a») to be true'
    1313  strict mode: 'Test262Error: Expected SameValue(«», «a») to be true'
    14 test/annexB/built-ins/RegExp/prototype/compile/pattern-string-invalid-u.js:
    15   default: 'Test262Error: invalid pattern: { Expected a SyntaxError to be thrown but no exception was thrown at all'
    16   strict mode: 'Test262Error: invalid pattern: { Expected a SyntaxError to be thrown but no exception was thrown at all'
    1714test/annexB/language/eval-code/direct/func-block-decl-eval-func-skip-early-err-block.js:
    1815  default: 'Test262Error: An initialized binding is not created prior to evaluation Expected a ReferenceError to be thrown but no exception was thrown at all'
     
    15201517  default: 'Test262Error: `\p{XID_Start}` should match U+001CFA (`ᳺ`)'
    15211518  strict mode: 'Test262Error: `\p{XID_Start}` should match U+001CFA (`ᳺ`)'
    1522 test/built-ins/RegExp/property-escapes/non-existent-property-value-General_Category-negated.js:
    1523   default: 'Test262: This statement should not be evaluated.'
    1524   strict mode: 'Test262: This statement should not be evaluated.'
    1525 test/built-ins/RegExp/property-escapes/non-existent-property-value-Script-negated.js:
    1526   default: 'Test262: This statement should not be evaluated.'
    1527   strict mode: 'Test262: This statement should not be evaluated.'
    1528 test/built-ins/RegExp/property-escapes/non-existent-property-value-Script.js:
    1529   default: 'Test262: This statement should not be evaluated.'
    1530   strict mode: 'Test262: This statement should not be evaluated.'
    1531 test/built-ins/RegExp/property-escapes/non-existent-property-value-Script_Extensions-negated.js:
    1532   default: 'Test262: This statement should not be evaluated.'
    1533   strict mode: 'Test262: This statement should not be evaluated.'
    1534 test/built-ins/RegExp/property-escapes/non-existent-property-value-Script_Extensions.js:
    1535   default: 'Test262: This statement should not be evaluated.'
    1536   strict mode: 'Test262: This statement should not be evaluated.'
    1537 test/built-ins/RegExp/property-escapes/non-existent-property-value-general-category.js:
    1538   default: 'Test262: This statement should not be evaluated.'
    1539   strict mode: 'Test262: This statement should not be evaluated.'
    15401519test/built-ins/RegExp/proto-from-ctor-realm.js:
    15411520  default: 'Test262Error: Expected SameValue(«/(?:)/», «/(?:)/») to be true'
     
    16071586  default: 'Test262Error: Expected a SyntaxError to be thrown but no exception was thrown at all'
    16081587  strict mode: 'Test262Error: Expected a SyntaxError to be thrown but no exception was thrown at all'
    1609 test/built-ins/RegExp/unicode_restricted_incomple_quantifier.js:
    1610   default: 'Test262Error: RegExp("a{", "u"):  Expected a SyntaxError to be thrown but no exception was thrown at all'
    1611   strict mode: 'Test262Error: RegExp("a{", "u"):  Expected a SyntaxError to be thrown but no exception was thrown at all'
    16121588test/built-ins/RegExp/unicode_restricted_octal_escape.js:
    16131589  default: 'Test262Error: RegExp("[\1]", "u"):  Expected a SyntaxError to be thrown but no exception was thrown at all'
     
    34033379  default: 'Test262: This statement should not be evaluated.'
    34043380  strict mode: 'Test262: This statement should not be evaluated.'
    3405 test/language/literals/regexp/u-invalid-extended-pattern-char.js:
    3406   default: 'Test262: This statement should not be evaluated.'
    3407   strict mode: 'Test262: This statement should not be evaluated.'
    34083381test/language/literals/regexp/u-invalid-legacy-octal-escape.js:
    34093382  default: 'Test262: This statement should not be evaluated.'
  • trunk/LayoutTests/ChangeLog

    r255448 r255452  
     12020-01-30  Alexey Shvayka  <shvaikalesh@gmail.com>
     2
     3        Incomplete braced quantifiers should be banned in Unicode patterns only
     4        https://bugs.webkit.org/show_bug.cgi?id=206776
     5
     6        Reviewed by Darin Adler.
     7
     8        An error message test is added for this change and for webkit.org/b/206768.
     9        Other tests are adjusted for capitalized "Unicode" in error messages.
     10
     11        * js/regexp-named-capture-groups-expected.txt:
     12        * js/regexp-unicode-expected.txt:
     13        * js/regress-158080-expected.txt:
     14        * js/script-tests/regexp-named-capture-groups.js:
     15        * js/script-tests/regexp-unicode.js:
     16
    1172020-01-30  Doug Kelly  <dougk@apple.com>
    218
  • trunk/LayoutTests/js/regexp-named-capture-groups-expected.txt

    r235882 r255452  
    5050PASS "Give me \'k2\'!".match(/Give me \'\k2\'/)[0] is "Give me \'k2\'"
    5151PASS "Give me a \'kat\'!".match(/Give me a \'\kat\'/)[0] is "Give me a \'kat\'"
    52 PASS "Give me a \'k\'!".match(/Give me a \'\k\'/u)[0] threw exception SyntaxError: Invalid regular expression: invalid escaped character for unicode pattern.
    53 PASS "Give me \'k2\'!".match(/Give me \'\k2\'/u)[0] threw exception SyntaxError: Invalid regular expression: invalid escaped character for unicode pattern.
    54 PASS "Give me a \'kat\'!".match(/Give me a \'\kat\'/u)[0] threw exception SyntaxError: Invalid regular expression: invalid escaped character for unicode pattern.
     52PASS "Give me a \'k\'!".match(/Give me a \'\k\'/u)[0] threw exception SyntaxError: Invalid regular expression: invalid escaped character for Unicode pattern.
     53PASS "Give me \'k2\'!".match(/Give me \'\k2\'/u)[0] threw exception SyntaxError: Invalid regular expression: invalid escaped character for Unicode pattern.
     54PASS "Give me a \'kat\'!".match(/Give me a \'\kat\'/u)[0] threw exception SyntaxError: Invalid regular expression: invalid escaped character for Unicode pattern.
    5555PASS "10/20/1930".replace(/(?<month>\d{2})\/(?<day>\d{2})\/(?<year>\d{4})/, "$<day>-$<mouth>-$<year>") is "20--1930"
    5656PASS "10/20/1930".replace(/(?<month>\d{2})\/(?<day>\d{2})\/(?<year>\d{4})/, "$<day>-$<month>-$<year") is "20-10-$<year"
     
    6767PASS "1122332211".match(/\k<ones>\k<twos>\k<threes>(?<ones>1*)(?<twos>2*)(?<threes>3*)\k<threes>\k<twos>\k<ones>/u) is ["1122332211", "11", "22", "3"]
    6868PASS "\k<z>XzzX".match(/\k<z>X(z*)X/) is ["k<z>XzzX", "zz"]
    69 PASS "\k<z>XzzX".match(/\k<z>X(z*)X/u) threw exception SyntaxError: Invalid regular expression: invalid backreference for unicode pattern.
     69PASS "\k<z>XzzX".match(/\k<z>X(z*)X/u) threw exception SyntaxError: Invalid regular expression: invalid backreference for Unicode pattern.
    7070PASS successfullyParsed is true
    7171
  • trunk/LayoutTests/js/regexp-unicode-expected.txt

    r243839 r255452  
    164164PASS "this is ba test".match(/is b\cha test/u)[0].length is 11
    165165PASS new RegExp("\\/", "u").source is "\\/"
    166 PASS r = new RegExp("\\u{110000}", "u") threw exception SyntaxError: Invalid regular expression: invalid unicode {} escape.
     166PASS r = new RegExp("\\u{110000}", "u") threw exception SyntaxError: Invalid regular expression: invalid Unicode {} escape.
    167167PASS r = new RegExp("𐐅{2147483648}", "u") threw exception SyntaxError: Invalid regular expression: pattern exceeds string length limits.
    168 PASS r = new RegExp("\\-", "u") threw exception SyntaxError: Invalid regular expression: invalid escaped character for unicode pattern.
    169 PASS r = new RegExp("\\a", "u") threw exception SyntaxError: Invalid regular expression: invalid escaped character for unicode pattern.
    170 PASS r = new RegExp("[\\a]", "u") threw exception SyntaxError: Invalid regular expression: invalid escaped character for unicode pattern.
    171 PASS r = new RegExp("[\\b]", "u") threw exception SyntaxError: Invalid regular expression: invalid escaped character for unicode pattern.
    172 PASS r = new RegExp("[\\B]", "u") threw exception SyntaxError: Invalid regular expression: invalid escaped character for unicode pattern.
    173 PASS r = new RegExp("\\x", "u") threw exception SyntaxError: Invalid regular expression: invalid escaped character for unicode pattern.
    174 PASS r = new RegExp("[\\x]", "u") threw exception SyntaxError: Invalid regular expression: invalid escaped character for unicode pattern.
    175 PASS r = new RegExp("\\u", "u") threw exception SyntaxError: Invalid regular expression: invalid escaped character for unicode pattern.
    176 PASS r = new RegExp("[\\u]", "u") threw exception SyntaxError: Invalid regular expression: invalid escaped character for unicode pattern.
    177 PASS r = new RegExp("\\u{", "u") threw exception SyntaxError: Invalid regular expression: invalid unicode {} escape.
    178 PASS r = new RegExp("\\u{\udead", "u") threw exception SyntaxError: Invalid regular expression: invalid unicode {} escape.
    179 PASS /\1/u threw exception SyntaxError: Invalid regular expression: invalid backreference for unicode pattern.
    180 PASS /\2/u threw exception SyntaxError: Invalid regular expression: invalid backreference for unicode pattern.
    181 PASS /\3/u threw exception SyntaxError: Invalid regular expression: invalid backreference for unicode pattern.
    182 PASS /\4/u threw exception SyntaxError: Invalid regular expression: invalid backreference for unicode pattern.
    183 PASS /\5/u threw exception SyntaxError: Invalid regular expression: invalid backreference for unicode pattern.
    184 PASS /\6/u threw exception SyntaxError: Invalid regular expression: invalid backreference for unicode pattern.
    185 PASS /\7/u threw exception SyntaxError: Invalid regular expression: invalid backreference for unicode pattern.
    186 PASS /\8/u threw exception SyntaxError: Invalid regular expression: invalid backreference for unicode pattern.
    187 PASS /\9/u threw exception SyntaxError: Invalid regular expression: invalid backreference for unicode pattern.
     168PASS /{/u threw exception SyntaxError: Invalid regular expression: incomplete {} quantifier for Unicode pattern.
     169PASS /[a-\d]/u threw exception SyntaxError: Invalid regular expression: invalid range in character class for Unicode pattern.
     170PASS r = new RegExp("\\-", "u") threw exception SyntaxError: Invalid regular expression: invalid escaped character for Unicode pattern.
     171PASS r = new RegExp("\\a", "u") threw exception SyntaxError: Invalid regular expression: invalid escaped character for Unicode pattern.
     172PASS r = new RegExp("[\\a]", "u") threw exception SyntaxError: Invalid regular expression: invalid escaped character for Unicode pattern.
     173PASS r = new RegExp("[\\b]", "u") threw exception SyntaxError: Invalid regular expression: invalid escaped character for Unicode pattern.
     174PASS r = new RegExp("[\\B]", "u") threw exception SyntaxError: Invalid regular expression: invalid escaped character for Unicode pattern.
     175PASS r = new RegExp("\\x", "u") threw exception SyntaxError: Invalid regular expression: invalid escaped character for Unicode pattern.
     176PASS r = new RegExp("[\\x]", "u") threw exception SyntaxError: Invalid regular expression: invalid escaped character for Unicode pattern.
     177PASS r = new RegExp("\\u", "u") threw exception SyntaxError: Invalid regular expression: invalid escaped character for Unicode pattern.
     178PASS r = new RegExp("[\\u]", "u") threw exception SyntaxError: Invalid regular expression: invalid escaped character for Unicode pattern.
     179PASS r = new RegExp("\\u{", "u") threw exception SyntaxError: Invalid regular expression: invalid Unicode {} escape.
     180PASS r = new RegExp("\\u{\udead", "u") threw exception SyntaxError: Invalid regular expression: invalid Unicode {} escape.
     181PASS /\1/u threw exception SyntaxError: Invalid regular expression: invalid backreference for Unicode pattern.
     182PASS /\2/u threw exception SyntaxError: Invalid regular expression: invalid backreference for Unicode pattern.
     183PASS /\3/u threw exception SyntaxError: Invalid regular expression: invalid backreference for Unicode pattern.
     184PASS /\4/u threw exception SyntaxError: Invalid regular expression: invalid backreference for Unicode pattern.
     185PASS /\5/u threw exception SyntaxError: Invalid regular expression: invalid backreference for Unicode pattern.
     186PASS /\6/u threw exception SyntaxError: Invalid regular expression: invalid backreference for Unicode pattern.
     187PASS /\7/u threw exception SyntaxError: Invalid regular expression: invalid backreference for Unicode pattern.
     188PASS /\8/u threw exception SyntaxError: Invalid regular expression: invalid backreference for Unicode pattern.
     189PASS /\9/u threw exception SyntaxError: Invalid regular expression: invalid backreference for Unicode pattern.
    188190PASS /(.)\1/u did not throw exception.
    189191PASS /(.)(.)\2/u did not throw exception.
    190 PASS /(.)(.)\3/u threw exception SyntaxError: Invalid regular expression: invalid backreference for unicode pattern.
     192PASS /(.)(.)\3/u threw exception SyntaxError: Invalid regular expression: invalid backreference for Unicode pattern.
    191193PASS /\1/ did not throw exception.
    192194PASS /\2/ did not throw exception.
  • trunk/LayoutTests/js/regress-158080-expected.txt

    r203202 r255452  
    44
    55
    6 PASS let r = /\u{|abc/u threw exception SyntaxError: Invalid regular expression: invalid unicode {} escape.
    7 PASS let r = /\u{/u threw exception SyntaxError: Invalid regular expression: invalid unicode {} escape.
    8 PASS let r = /\u{1/u threw exception SyntaxError: Invalid regular expression: invalid unicode {} escape.
    9 PASS let r = /\u{12/u threw exception SyntaxError: Invalid regular expression: invalid unicode {} escape.
    10 PASS let r = /\u{123/u threw exception SyntaxError: Invalid regular expression: invalid unicode {} escape.
    11 PASS let r = /\u{1234/u threw exception SyntaxError: Invalid regular expression: invalid unicode {} escape.
    12 PASS let r = /\u{abcde/u threw exception SyntaxError: Invalid regular expression: invalid unicode {} escape.
    13 PASS let r = /\u{abcdef/u threw exception SyntaxError: Invalid regular expression: invalid unicode {} escape.
    14 PASS let r = /\u{1111111}/u threw exception SyntaxError: Invalid regular expression: invalid unicode {} escape.
    15 PASS let r = /\u{fedbca98}/u threw exception SyntaxError: Invalid regular expression: invalid unicode {} escape.
    16 PASS let r = /\u{1{123}}/u threw exception SyntaxError: Invalid regular expression: invalid unicode {} escape.
     6PASS let r = /\u{|abc/u threw exception SyntaxError: Invalid regular expression: invalid Unicode {} escape.
     7PASS let r = /\u{/u threw exception SyntaxError: Invalid regular expression: invalid Unicode {} escape.
     8PASS let r = /\u{1/u threw exception SyntaxError: Invalid regular expression: invalid Unicode {} escape.
     9PASS let r = /\u{12/u threw exception SyntaxError: Invalid regular expression: invalid Unicode {} escape.
     10PASS let r = /\u{123/u threw exception SyntaxError: Invalid regular expression: invalid Unicode {} escape.
     11PASS let r = /\u{1234/u threw exception SyntaxError: Invalid regular expression: invalid Unicode {} escape.
     12PASS let r = /\u{abcde/u threw exception SyntaxError: Invalid regular expression: invalid Unicode {} escape.
     13PASS let r = /\u{abcdef/u threw exception SyntaxError: Invalid regular expression: invalid Unicode {} escape.
     14PASS let r = /\u{1111111}/u threw exception SyntaxError: Invalid regular expression: invalid Unicode {} escape.
     15PASS let r = /\u{fedbca98}/u threw exception SyntaxError: Invalid regular expression: invalid Unicode {} escape.
     16PASS let r = /\u{1{123}}/u threw exception SyntaxError: Invalid regular expression: invalid Unicode {} escape.
    1717PASS successfullyParsed is true
    1818
  • trunk/LayoutTests/js/script-tests/regexp-named-capture-groups.js

    r235882 r255452  
    8686shouldBe('"Give me a \\\'kat\\\'!".match(/Give me a \\\'\\\kat\\\'/)[0]', '"Give me a \\\'kat\\\'"');
    8787// Verify that named back references for non-existing named group matches the k<groupName> throw for unicode patterns.
    88 shouldThrow('"Give me a \\\'k\\\'!".match(/Give me a \\\'\\\k\\\'/u)[0]', '"SyntaxError: Invalid regular expression: invalid escaped character for unicode pattern"');
    89 shouldThrow('"Give me \\\'k2\\\'!".match(/Give me \\\'\\\k2\\\'/u)[0]', '"SyntaxError: Invalid regular expression: invalid escaped character for unicode pattern"');
    90 shouldThrow('"Give me a \\\'kat\\\'!".match(/Give me a \\\'\\\kat\\\'/u)[0]', '"SyntaxError: Invalid regular expression: invalid escaped character for unicode pattern"');
     88shouldThrow('"Give me a \\\'k\\\'!".match(/Give me a \\\'\\\k\\\'/u)[0]', '"SyntaxError: Invalid regular expression: invalid escaped character for Unicode pattern"');
     89shouldThrow('"Give me \\\'k2\\\'!".match(/Give me \\\'\\\k2\\\'/u)[0]', '"SyntaxError: Invalid regular expression: invalid escaped character for Unicode pattern"');
     90shouldThrow('"Give me a \\\'kat\\\'!".match(/Give me a \\\'\\\kat\\\'/u)[0]', '"SyntaxError: Invalid regular expression: invalid escaped character for Unicode pattern"');
    9191
    9292// Check invalid group name specifiers in a replace string.
     
    114114// matches for non-unicode patterns and throws for unicode patterns.
    115115shouldBe('"\\\k<z>XzzX".match(/\\\k<z>X(z*)X/)', '["k<z>XzzX", "zz"]');
    116 shouldThrow('"\\\k<z>XzzX".match(/\\\k<z>X(z*)X/u)', '"SyntaxError: Invalid regular expression: invalid backreference for unicode pattern"');
     116shouldThrow('"\\\k<z>XzzX".match(/\\\k<z>X(z*)X/u)', '"SyntaxError: Invalid regular expression: invalid backreference for Unicode pattern"');
  • trunk/LayoutTests/js/script-tests/regexp-unicode.js

    r243839 r255452  
    229229// Check that invalid unicode patterns throw exceptions
    230230shouldBe('new RegExp("\\\\/", "u").source', '"\\\\/"');
    231 shouldThrow('r = new RegExp("\\\\u{110000}", "u")', '"SyntaxError: Invalid regular expression: invalid unicode {} escape"');
     231shouldThrow('r = new RegExp("\\\\u{110000}", "u")', '"SyntaxError: Invalid regular expression: invalid Unicode {} escape"');
    232232shouldThrow('r = new RegExp("\u{10405}{2147483648}", "u")', '"SyntaxError: Invalid regular expression: pattern exceeds string length limits"');
    233 
    234 var invalidEscapeException = "SyntaxError: Invalid regular expression: invalid escaped character for unicode pattern";
     233shouldThrow('/{/u', '"SyntaxError: Invalid regular expression: incomplete {} quantifier for Unicode pattern"');
     234shouldThrow('/[a-\\d]/u', '"SyntaxError: Invalid regular expression: invalid range in character class for Unicode pattern"');
     235
     236var invalidEscapeException = "SyntaxError: Invalid regular expression: invalid escaped character for Unicode pattern";
    235237var newRegExp;
    236238
     
    252254shouldThrowInvalidEscape("[\\\\u]");
    253255
    254 shouldThrowInvalidEscape("\\\\u{", '"SyntaxError: Invalid regular expression: invalid unicode {} escape"');
    255 shouldThrowInvalidEscape("\\\\u{\\udead", '"SyntaxError: Invalid regular expression: invalid unicode {} escape"');
     256shouldThrowInvalidEscape("\\\\u{", '"SyntaxError: Invalid regular expression: invalid Unicode {} escape"');
     257shouldThrowInvalidEscape("\\\\u{\\udead", '"SyntaxError: Invalid regular expression: invalid Unicode {} escape"');
    256258
    257259// Check that invalid backreferences in unicode patterns throw exceptions.
  • trunk/Source/JavaScriptCore/ChangeLog

    r255449 r255452  
     12020-01-30  Alexey Shvayka  <shvaikalesh@gmail.com>
     2
     3        Incomplete braced quantifiers should be banned in Unicode patterns only
     4        https://bugs.webkit.org/show_bug.cgi?id=206776
     5
     6        Reviewed by Darin Adler.
     7
     8        This change adds SyntaxError for Unicode patterns, aligning JSC with
     9        V8 and SpiderMonkey, and also capitalizes "Unicode" in error messages.
     10
     11        Grammar: https://tc39.es/ecma262/#prod-annexB-Term
     12        (/u flag precludes the use of ExtendedAtom and thus InvalidBracedQuantifier)
     13
     14        * yarr/YarrErrorCode.cpp:
     15        (JSC::Yarr::errorMessage):
     16        (JSC::Yarr::errorToThrow):
     17        * yarr/YarrErrorCode.h:
     18        * yarr/YarrParser.h:
     19        (JSC::Yarr::Parser::parseTokens):
     20
    1212020-01-30  Yusuke Suzuki  <ysuzuki@apple.com>
    222
     
    3814012020-01-26  Alexey Shvayka  <shvaikalesh@gmail.com>
    382402
    383         Invalid ranges in character classes should be banned in unicode patterns
     403        Invalid ranges in character classes should be banned in Unicode patterns only
    384404        https://bugs.webkit.org/show_bug.cgi?id=206768
    385405
     
    388408        In ES5, grammar of CharacterRange was ambiguous, resulting in invalid ranges
    389409        like /[\d-a]/ being allowed. As of ES2015, invalid ranges are SyntaxError in
    390         unicode patterns, yet still allowed in regular ones to avoid breaking the web.
     410        Unicode patterns, yet still allowed in regular ones to avoid breaking the web.
    391411        (https://tc39.es/ecma262/#sec-patterns-static-semantics-early-errors-annexb)
    392412
    393         This change adds SyntaxError for unicode patterns and updates explanatory
     413        This change adds SyntaxError for Unicode patterns and updates explanatory
    394414        comments. ErrorCode::CharacterClassOutOfOrder is renamed for consistency
    395415        with newly added error code and ErrorCode::ParenthesesTypeInvalid.
  • trunk/Source/JavaScriptCore/yarr/YarrErrorCode.cpp

    r255134 r255452  
    4141        REGEXP_ERROR_PREFIX "nothing to repeat",                                    // QuantifierWithoutAtom
    4242        REGEXP_ERROR_PREFIX "number too large in {} quantifier",                    // QuantifierTooLarge
     43        REGEXP_ERROR_PREFIX "incomplete {} quantifier for Unicode pattern",         // QuantifierIncomplete
    4344        REGEXP_ERROR_PREFIX "missing )",                                            // MissingParentheses
    4445        REGEXP_ERROR_PREFIX "unmatched parentheses",                                // ParenthesesUnmatched
     
    4849        REGEXP_ERROR_PREFIX "missing terminating ] for character class",            // CharacterClassUnmatched
    4950        REGEXP_ERROR_PREFIX "range out of order in character class",                // CharacterClassRangeOutOfOrder
    50         REGEXP_ERROR_PREFIX "invalid range in character class for unicode pattern", // CharacterClassRangeInvalid
     51        REGEXP_ERROR_PREFIX "invalid range in character class for Unicode pattern", // CharacterClassRangeInvalid
    5152        REGEXP_ERROR_PREFIX "\\ at end of pattern",                                 // EscapeUnterminated
    52         REGEXP_ERROR_PREFIX "invalid unicode {} escape",                            // InvalidUnicodeEscape
    53         REGEXP_ERROR_PREFIX "invalid backreference for unicode pattern",            // InvalidBackreference
    54         REGEXP_ERROR_PREFIX "invalid escaped character for unicode pattern",        // InvalidIdentityEscape
     53        REGEXP_ERROR_PREFIX "invalid Unicode {} escape",                            // InvalidUnicodeEscape
     54        REGEXP_ERROR_PREFIX "invalid backreference for Unicode pattern",            // InvalidBackreference
     55        REGEXP_ERROR_PREFIX "invalid escaped character for Unicode pattern",        // InvalidIdentityEscape
    5556        REGEXP_ERROR_PREFIX "invalid property expression",                          // InvalidUnicodePropertyExpression
    5657        REGEXP_ERROR_PREFIX "too many nested disjunctions",                         // TooManyDisjunctions
     
    7273    case ErrorCode::QuantifierWithoutAtom:
    7374    case ErrorCode::QuantifierTooLarge:
     75    case ErrorCode::QuantifierIncomplete:
    7476    case ErrorCode::MissingParentheses:
    7577    case ErrorCode::ParenthesesUnmatched:
  • trunk/Source/JavaScriptCore/yarr/YarrErrorCode.h

    r255134 r255452  
    4040    QuantifierWithoutAtom,
    4141    QuantifierTooLarge,
     42    QuantifierIncomplete,
    4243    MissingParentheses,
    4344    ParenthesesUnmatched,
  • trunk/Source/JavaScriptCore/yarr/YarrParser.h

    r255134 r255452  
    818818                }
    819819
     820                if (m_isUnicode) {
     821                    m_errorCode = ErrorCode::QuantifierIncomplete;
     822                    break;
     823                }
     824
    820825                restoreState(state);
    821             }
    822             // if we did not find a complete quantifer, fall through to the default case.
    823             FALLTHROUGH;
     826                // if we did not find a complete quantifer, fall through to the default case.
     827                FALLTHROUGH;
     828            }
    824829
    825830            default:
Note: See TracChangeset for help on using the changeset viewer.