Title: [255505] trunk
Revision
255505
Author
shvaikal...@gmail.com
Date
2020-01-31 09:59:26 -0800 (Fri, 31 Jan 2020)

Log Message

Unmatched ] or } brackets should be syntax errors in Unicode patterns only
https://bugs.webkit.org/show_bug.cgi?id=207023

Reviewed by Darin Adler.

JSTests:

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

Source/_javascript_Core:

This change adds SyntaxError for Unicode patterns, aligning JSC with
V8 and SpiderMonkey.

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

* yarr/YarrErrorCode.cpp:
(JSC::Yarr::errorMessage):
(JSC::Yarr::errorToThrow):
* yarr/YarrErrorCode.h:
* yarr/YarrParser.h:
(JSC::Yarr::Parser::parseTokens):

LayoutTests:

* js/regexp-unicode-expected.txt:
* js/script-tests/regexp-unicode.js:

Modified Paths

Diff

Modified: trunk/JSTests/ChangeLog (255504 => 255505)


--- trunk/JSTests/ChangeLog	2020-01-31 17:58:19 UTC (rev 255504)
+++ trunk/JSTests/ChangeLog	2020-01-31 17:59:26 UTC (rev 255505)
@@ -1,3 +1,12 @@
+2020-01-31  Alexey Shvayka  <shvaikal...@gmail.com>
+
+        Unmatched ] or } brackets should be syntax errors in Unicode patterns only
+        https://bugs.webkit.org/show_bug.cgi?id=207023
+
+        Reviewed by Darin Adler.
+
+        * test262/expectations.yaml: Mark 2 test cases as passing.
+
 2020-01-30  Alexey Shvayka  <shvaikal...@gmail.com>
 
         Incomplete braced quantifiers should be banned in Unicode patterns only

Modified: trunk/JSTests/test262/expectations.yaml (255504 => 255505)


--- trunk/JSTests/test262/expectations.yaml	2020-01-31 17:58:19 UTC (rev 255504)
+++ trunk/JSTests/test262/expectations.yaml	2020-01-31 17:59:26 UTC (rev 255505)
@@ -1573,9 +1573,6 @@
 test/built-ins/RegExp/prototype/unicode/cross-realm.js:
   default: 'Test262Error: cross-realm RegExp.prototype Expected a TypeError to be thrown but no exception was thrown at all'
   strict mode: 'Test262Error: cross-realm RegExp.prototype Expected a TypeError to be thrown but no exception was thrown at all'
-test/built-ins/RegExp/unicode_restricted_brackets.js:
-  default: 'Test262Error: RegExp("]", "u"):  Expected a SyntaxError to be thrown but no exception was thrown at all'
-  strict mode: 'Test262Error: RegExp("]", "u"):  Expected a SyntaxError to be thrown but no exception was thrown at all'
 test/built-ins/RegExp/unicode_restricted_identity_escape.js:
   default: "Test262Error: Invalid IdentityEscape in AtomEscape: '\\"
   strict mode: "Test262Error: Invalid IdentityEscape in AtomEscape: '\\"

Modified: trunk/LayoutTests/ChangeLog (255504 => 255505)


--- trunk/LayoutTests/ChangeLog	2020-01-31 17:58:19 UTC (rev 255504)
+++ trunk/LayoutTests/ChangeLog	2020-01-31 17:59:26 UTC (rev 255505)
@@ -1,3 +1,13 @@
+2020-01-31  Alexey Shvayka  <shvaikal...@gmail.com>
+
+        Unmatched ] or } brackets should be syntax errors in Unicode patterns only
+        https://bugs.webkit.org/show_bug.cgi?id=207023
+
+        Reviewed by Darin Adler.
+
+        * js/regexp-unicode-expected.txt:
+        * js/script-tests/regexp-unicode.js:
+
 2020-01-31  Antoine Quint  <grao...@apple.com>
 
         [Web Animations] [WK1] REGRESSION: opacity doesn't animate

Modified: trunk/LayoutTests/js/regexp-unicode-expected.txt (255504 => 255505)


--- trunk/LayoutTests/js/regexp-unicode-expected.txt	2020-01-31 17:58:19 UTC (rev 255504)
+++ trunk/LayoutTests/js/regexp-unicode-expected.txt	2020-01-31 17:59:26 UTC (rev 255505)
@@ -167,6 +167,7 @@
 PASS r = new RegExp("𐐅{2147483648}", "u") threw exception SyntaxError: Invalid regular _expression_: pattern exceeds string length limits.
 PASS /{/u threw exception SyntaxError: Invalid regular _expression_: incomplete {} quantifier for Unicode pattern.
 PASS /[a-\d]/u threw exception SyntaxError: Invalid regular _expression_: invalid range in character class for Unicode pattern.
+PASS /]/u threw exception SyntaxError: Invalid regular _expression_: unmatched ] or } bracket for Unicode pattern.
 PASS r = new RegExp("\\-", "u") threw exception SyntaxError: Invalid regular _expression_: invalid escaped character for Unicode pattern.
 PASS r = new RegExp("\\a", "u") threw exception SyntaxError: Invalid regular _expression_: invalid escaped character for Unicode pattern.
 PASS r = new RegExp("[\\a]", "u") threw exception SyntaxError: Invalid regular _expression_: invalid escaped character for Unicode pattern.

Modified: trunk/LayoutTests/js/script-tests/regexp-unicode.js (255504 => 255505)


--- trunk/LayoutTests/js/script-tests/regexp-unicode.js	2020-01-31 17:58:19 UTC (rev 255504)
+++ trunk/LayoutTests/js/script-tests/regexp-unicode.js	2020-01-31 17:59:26 UTC (rev 255505)
@@ -232,6 +232,7 @@
 shouldThrow('r = new RegExp("\u{10405}{2147483648}", "u")', '"SyntaxError: Invalid regular _expression_: pattern exceeds string length limits"');
 shouldThrow('/{/u', '"SyntaxError: Invalid regular _expression_: incomplete {} quantifier for Unicode pattern"');
 shouldThrow('/[a-\\d]/u', '"SyntaxError: Invalid regular _expression_: invalid range in character class for Unicode pattern"');
+shouldThrow('/]/u', '"SyntaxError: Invalid regular _expression_: unmatched ] or } bracket for Unicode pattern"');
 
 var invalidEscapeException = "SyntaxError: Invalid regular _expression_: invalid escaped character for Unicode pattern";
 var newRegExp;

Modified: trunk/Source/_javascript_Core/ChangeLog (255504 => 255505)


--- trunk/Source/_javascript_Core/ChangeLog	2020-01-31 17:58:19 UTC (rev 255504)
+++ trunk/Source/_javascript_Core/ChangeLog	2020-01-31 17:59:26 UTC (rev 255505)
@@ -1,3 +1,23 @@
+2020-01-31  Alexey Shvayka  <shvaikal...@gmail.com>
+
+        Unmatched ] or } brackets should be syntax errors in Unicode patterns only
+        https://bugs.webkit.org/show_bug.cgi?id=207023
+
+        Reviewed by Darin Adler.
+
+        This change adds SyntaxError for Unicode patterns, aligning JSC with
+        V8 and SpiderMonkey.
+
+        Grammar: https://tc39.es/ecma262/#prod-annexB-Term
+        (/u flag precludes the use of ExtendedAtom and thus ExtendedPatternCharacter)
+
+        * yarr/YarrErrorCode.cpp:
+        (JSC::Yarr::errorMessage):
+        (JSC::Yarr::errorToThrow):
+        * yarr/YarrErrorCode.h:
+        * yarr/YarrParser.h:
+        (JSC::Yarr::Parser::parseTokens):
+
 2020-01-31  Don Olmstead  <don.olmst...@sony.com>
 
         [CMake] Add _PRIVATE_LIBRARIES to framework

Modified: trunk/Source/_javascript_Core/yarr/YarrErrorCode.cpp (255504 => 255505)


--- trunk/Source/_javascript_Core/yarr/YarrErrorCode.cpp	2020-01-31 17:58:19 UTC (rev 255504)
+++ trunk/Source/_javascript_Core/yarr/YarrErrorCode.cpp	2020-01-31 17:59:26 UTC (rev 255505)
@@ -42,6 +42,7 @@
         REGEXP_ERROR_PREFIX "number too large in {} quantifier",                    // QuantifierTooLarge
         REGEXP_ERROR_PREFIX "incomplete {} quantifier for Unicode pattern",         // QuantifierIncomplete
         REGEXP_ERROR_PREFIX "missing )",                                            // MissingParentheses
+        REGEXP_ERROR_PREFIX "unmatched ] or } bracket for Unicode pattern",         // BracketUnmatched
         REGEXP_ERROR_PREFIX "unmatched parentheses",                                // ParenthesesUnmatched
         REGEXP_ERROR_PREFIX "unrecognized character after (?",                      // ParenthesesTypeInvalid
         REGEXP_ERROR_PREFIX "invalid group specifier name",                         // InvalidGroupName
@@ -74,6 +75,7 @@
     case ErrorCode::QuantifierTooLarge:
     case ErrorCode::QuantifierIncomplete:
     case ErrorCode::MissingParentheses:
+    case ErrorCode::BracketUnmatched:
     case ErrorCode::ParenthesesUnmatched:
     case ErrorCode::ParenthesesTypeInvalid:
     case ErrorCode::InvalidGroupName:

Modified: trunk/Source/_javascript_Core/yarr/YarrErrorCode.h (255504 => 255505)


--- trunk/Source/_javascript_Core/yarr/YarrErrorCode.h	2020-01-31 17:58:19 UTC (rev 255504)
+++ trunk/Source/_javascript_Core/yarr/YarrErrorCode.h	2020-01-31 17:59:26 UTC (rev 255505)
@@ -41,6 +41,7 @@
     QuantifierTooLarge,
     QuantifierIncomplete,
     MissingParentheses,
+    BracketUnmatched,
     ParenthesesUnmatched,
     ParenthesesTypeInvalid,
     InvalidGroupName,

Modified: trunk/Source/_javascript_Core/yarr/YarrParser.h (255504 => 255505)


--- trunk/Source/_javascript_Core/yarr/YarrParser.h	2020-01-31 17:58:19 UTC (rev 255504)
+++ trunk/Source/_javascript_Core/yarr/YarrParser.h	2020-01-31 17:59:26 UTC (rev 255505)
@@ -774,6 +774,17 @@
                 lastTokenWasAnAtom = true;
                 break;
 
+            case ']':
+            case '}':
+                if (m_isUnicode) {
+                    m_errorCode = ErrorCode::BracketUnmatched;
+                    break;
+                }
+
+                m_delegate.atomPatternCharacter(consume());
+                lastTokenWasAnAtom = true;
+                break;
+
             case '\\':
                 lastTokenWasAnAtom = parseAtomEscape();
                 break;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to