Changeset 258976 in webkit


Ignore:
Timestamp:
Mar 25, 2020 4:11:47 AM (4 years ago)
Author:
Alexey Shvayka
Message:

\b escapes inside character classes should be valid in Unicode patterns
https://bugs.webkit.org/show_bug.cgi?id=209528

Reviewed by Darin Adler.

JSTests:

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

Source/JavaScriptCore:

This change removes isIdentityEscapeAnError('b') check, allowing \b escapes
inside character classes in Unicode patterns match U+0008 (BACKSPACE) characters,
aligning JSC with V8 and SpiderMonkey.

Grammar: https://tc39.es/ecma262/#prod-ClassEscape
('b' comes before CharacterEscape :: IdentityEscape)

  • yarr/YarrParser.h:

(JSC::Yarr::Parser::parseEscape):

LayoutTests:

  • js/regexp-unicode-expected.txt:
  • js/script-tests/regexp-unicode.js:
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r258965 r258976  
     12020-03-25  Alexey Shvayka  <shvaikalesh@gmail.com>
     2
     3        \b escapes inside character classes should be valid in Unicode patterns
     4        https://bugs.webkit.org/show_bug.cgi?id=209528
     5
     6        Reviewed by Darin Adler.
     7
     8        * test262/expectations.yaml: Mark 2 test cases as passing.
     9
    1102020-03-24  Tadeu Zagallo  <tzagallo@apple.com>
    211
  • trunk/JSTests/test262/expectations.yaml

    r258963 r258976  
    17121712  default: 'SyntaxError: Invalid regular expression: number too large in {} quantifier'
    17131713  strict mode: 'SyntaxError: Invalid regular expression: number too large in {} quantifier'
    1714 test/built-ins/RegExp/unicode_character_class_backspace_escape.js:
    1715   default: 'SyntaxError: Invalid regular expression: invalid escaped character for Unicode pattern'
    1716   strict mode: 'SyntaxError: Invalid regular expression: invalid escaped character for Unicode pattern'
    17171714test/built-ins/RegExp/unicode_restricted_identity_escape_alpha.js:
    17181715  default: "Test262Error: IdentityEscape in AtomEscape: 'k' Expected a SyntaxError to be thrown but no exception was thrown at all"
  • trunk/LayoutTests/ChangeLog

    r258967 r258976  
     12020-03-25  Alexey Shvayka  <shvaikalesh@gmail.com>
     2
     3        \b escapes inside character classes should be valid in Unicode patterns
     4        https://bugs.webkit.org/show_bug.cgi?id=209528
     5
     6        Reviewed by Darin Adler.
     7
     8        * js/regexp-unicode-expected.txt:
     9        * js/script-tests/regexp-unicode.js:
     10
    1112020-03-24  Zalan Bujtas  <zalan@apple.com>
    212
  • trunk/LayoutTests/js/regexp-unicode-expected.txt

    r255975 r258976  
    188188PASS r = new RegExp("\\a", "u") threw exception SyntaxError: Invalid regular expression: invalid escaped character for Unicode pattern.
    189189PASS r = new RegExp("[\\a]", "u") threw exception SyntaxError: Invalid regular expression: invalid escaped character for Unicode pattern.
    190 PASS r = new RegExp("[\\b]", "u") threw exception SyntaxError: Invalid regular expression: invalid escaped character for Unicode pattern.
    191190PASS r = new RegExp("[\\B]", "u") threw exception SyntaxError: Invalid regular expression: invalid escaped character for Unicode pattern.
    192191PASS r = new RegExp("\\x", "u") threw exception SyntaxError: Invalid regular expression: invalid escaped character for Unicode pattern.
  • trunk/LayoutTests/js/script-tests/regexp-unicode.js

    r255975 r258976  
    248248shouldThrowInvalidEscape("\\\\a");
    249249shouldThrowInvalidEscape("[\\\\a]");
    250 shouldThrowInvalidEscape("[\\\\b]");
    251250shouldThrowInvalidEscape("[\\\\B]");
    252251shouldThrowInvalidEscape("\\\\x");
  • trunk/Source/JavaScriptCore/ChangeLog

    r258968 r258976  
     12020-03-25  Alexey Shvayka  <shvaikalesh@gmail.com>
     2
     3        \b escapes inside character classes should be valid in Unicode patterns
     4        https://bugs.webkit.org/show_bug.cgi?id=209528
     5
     6        Reviewed by Darin Adler.
     7
     8        This change removes isIdentityEscapeAnError('b') check, allowing \b escapes
     9        inside character classes in Unicode patterns match U+0008 (BACKSPACE) characters,
     10        aligning JSC with V8 and SpiderMonkey.
     11
     12        Grammar: https://tc39.es/ecma262/#prod-ClassEscape
     13        ('b' comes before CharacterEscape :: IdentityEscape)
     14
     15        * yarr/YarrParser.h:
     16        (JSC::Yarr::Parser::parseEscape):
     17
    1182020-03-24  Ross Kirsling  <ross.kirsling@sony.com>
    219
  • trunk/Source/JavaScriptCore/yarr/YarrParser.h

    r255689 r258976  
    276276        case 'b':
    277277            consume();
    278             if (inCharacterClass) {
    279                 if (isIdentityEscapeAnError('b'))
    280                     break;
    281 
     278            if (inCharacterClass)
    282279                delegate.atomPatternCharacter('\b');
    283             } else {
     280            else {
    284281                delegate.assertionWordBoundary(false);
    285282                return false;
Note: See TracChangeset for help on using the changeset viewer.