Title: [215311] trunk
Revision
215311
Author
[email protected]
Date
2017-04-12 19:51:18 -0700 (Wed, 12 Apr 2017)

Log Message

test262: test262/test/language/literals/regexp/u-dec-esc.js
https://bugs.webkit.org/show_bug.cgi?id=170687

Patch by Joseph Pecoraro <[email protected]> on 2017-04-12
Reviewed by Michael Saboff.

JSTests:

* test262.yaml:

Source/_javascript_Core:

* yarr/YarrParser.h:
(JSC::Yarr::Parser::parseEscape):
* yarr/YarrPattern.cpp:
(JSC::Yarr::YarrPattern::errorMessage):
(JSC::Yarr::YarrPattern::compile):
* yarr/YarrPattern.h:
In unicoe patterns, invalid backreferences are an error.

LayoutTests:

* js/regexp-unicode-expected.txt:
* js/script-tests/regexp-unicode.js:
Extend test to test invalid backreferences.

Modified Paths

Diff

Modified: trunk/JSTests/ChangeLog (215310 => 215311)


--- trunk/JSTests/ChangeLog	2017-04-13 02:26:53 UTC (rev 215310)
+++ trunk/JSTests/ChangeLog	2017-04-13 02:51:18 UTC (rev 215311)
@@ -1,3 +1,12 @@
+2017-04-12  Joseph Pecoraro  <[email protected]>
+
+        test262: test262/test/language/literals/regexp/u-dec-esc.js
+        https://bugs.webkit.org/show_bug.cgi?id=170687
+
+        Reviewed by Michael Saboff.
+
+        * test262.yaml:
+
 2017-04-11  Michael Saboff  <[email protected]>
 
         Implement Object.isFrozen() and Object.isSealed() per ECMA spec

Modified: trunk/JSTests/test262.yaml (215310 => 215311)


--- trunk/JSTests/test262.yaml	2017-04-13 02:26:53 UTC (rev 215310)
+++ trunk/JSTests/test262.yaml	2017-04-13 02:51:18 UTC (rev 215311)
@@ -71172,9 +71172,9 @@
 - path: test262/test/language/literals/regexp/u-case-mapping.js
   cmd: runTest262 :normal, "NoException", ["../../../../harness/assert.js", "../../../../harness/sta.js"], [:strict]
 - path: test262/test/language/literals/regexp/u-dec-esc.js
-  cmd: runTest262 :fail, "SyntaxError", ["../../../../harness/assert.js", "../../../../harness/sta.js"], []
+  cmd: runTest262 :normal, "SyntaxError", ["../../../../harness/assert.js", "../../../../harness/sta.js"], []
 - path: test262/test/language/literals/regexp/u-dec-esc.js
-  cmd: runTest262 :fail, "SyntaxError", ["../../../../harness/assert.js", "../../../../harness/sta.js"], [:strict]
+  cmd: runTest262 :normal, "SyntaxError", ["../../../../harness/assert.js", "../../../../harness/sta.js"], [:strict]
 - path: test262/test/language/literals/regexp/u-invalid-class-escape.js
   cmd: runTest262 :fail, "SyntaxError", ["../../../../harness/assert.js", "../../../../harness/sta.js"], []
 - path: test262/test/language/literals/regexp/u-invalid-class-escape.js
@@ -71188,9 +71188,9 @@
 - path: test262/test/language/literals/regexp/u-invalid-identity-escape.js
   cmd: runTest262 :normal, "SyntaxError", ["../../../../harness/assert.js", "../../../../harness/sta.js"], [:strict]
 - path: test262/test/language/literals/regexp/u-invalid-legacy-octal-escape.js
-  cmd: runTest262 :fail, "SyntaxError", ["../../../../harness/assert.js", "../../../../harness/sta.js"], []
+  cmd: runTest262 :normal, "SyntaxError", ["../../../../harness/assert.js", "../../../../harness/sta.js"], []
 - path: test262/test/language/literals/regexp/u-invalid-legacy-octal-escape.js
-  cmd: runTest262 :fail, "SyntaxError", ["../../../../harness/assert.js", "../../../../harness/sta.js"], [:strict]
+  cmd: runTest262 :normal, "SyntaxError", ["../../../../harness/assert.js", "../../../../harness/sta.js"], [:strict]
 - path: test262/test/language/literals/regexp/u-invalid-non-empty-class-ranges-no-dash-a.js
   cmd: runTest262 :fail, "SyntaxError", ["../../../../harness/assert.js", "../../../../harness/sta.js"], []
 - path: test262/test/language/literals/regexp/u-invalid-non-empty-class-ranges-no-dash-a.js
@@ -71208,9 +71208,9 @@
 - path: test262/test/language/literals/regexp/u-invalid-non-empty-class-ranges.js
   cmd: runTest262 :fail, "SyntaxError", ["../../../../harness/assert.js", "../../../../harness/sta.js"], [:strict]
 - path: test262/test/language/literals/regexp/u-invalid-oob-decimal-escape.js
-  cmd: runTest262 :fail, "SyntaxError", ["../../../../harness/assert.js", "../../../../harness/sta.js"], []
+  cmd: runTest262 :normal, "SyntaxError", ["../../../../harness/assert.js", "../../../../harness/sta.js"], []
 - path: test262/test/language/literals/regexp/u-invalid-oob-decimal-escape.js
-  cmd: runTest262 :fail, "SyntaxError", ["../../../../harness/assert.js", "../../../../harness/sta.js"], [:strict]
+  cmd: runTest262 :normal, "SyntaxError", ["../../../../harness/assert.js", "../../../../harness/sta.js"], [:strict]
 - path: test262/test/language/literals/regexp/u-invalid-quantifiable-assertion.js
   cmd: runTest262 :fail, "SyntaxError", ["../../../../harness/assert.js", "../../../../harness/sta.js"], []
 - path: test262/test/language/literals/regexp/u-invalid-quantifiable-assertion.js

Modified: trunk/LayoutTests/ChangeLog (215310 => 215311)


--- trunk/LayoutTests/ChangeLog	2017-04-13 02:26:53 UTC (rev 215310)
+++ trunk/LayoutTests/ChangeLog	2017-04-13 02:51:18 UTC (rev 215311)
@@ -1,3 +1,14 @@
+2017-04-12  Joseph Pecoraro  <[email protected]>
+
+        test262: test262/test/language/literals/regexp/u-dec-esc.js
+        https://bugs.webkit.org/show_bug.cgi?id=170687
+
+        Reviewed by Michael Saboff.
+
+        * js/regexp-unicode-expected.txt:
+        * js/script-tests/regexp-unicode.js:
+        Extend test to test invalid backreferences.
+
 2017-04-12  Jonathan Bedard  <[email protected]>
 
         Move expectation for compositing/iframes/iframe-size-from-zero.htm to top level

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


--- trunk/LayoutTests/js/regexp-unicode-expected.txt	2017-04-13 02:26:53 UTC (rev 215310)
+++ trunk/LayoutTests/js/regexp-unicode-expected.txt	2017-04-13 02:51:18 UTC (rev 215311)
@@ -150,6 +150,27 @@
 PASS r = new RegExp("[\\u]", "u") threw exception SyntaxError: Invalid regular _expression_: invalid escaped character for unicode pattern.
 PASS r = new RegExp("\\u{", "u") threw exception SyntaxError: Invalid regular _expression_: invalid unicode {} escape.
 PASS r = new RegExp("\\u{\udead", "u") threw exception SyntaxError: Invalid regular _expression_: invalid unicode {} escape.
+PASS /\1/u threw exception SyntaxError: Invalid regular _expression_: invalid backreference for unicode pattern.
+PASS /\2/u threw exception SyntaxError: Invalid regular _expression_: invalid backreference for unicode pattern.
+PASS /\3/u threw exception SyntaxError: Invalid regular _expression_: invalid backreference for unicode pattern.
+PASS /\4/u threw exception SyntaxError: Invalid regular _expression_: invalid backreference for unicode pattern.
+PASS /\5/u threw exception SyntaxError: Invalid regular _expression_: invalid backreference for unicode pattern.
+PASS /\6/u threw exception SyntaxError: Invalid regular _expression_: invalid backreference for unicode pattern.
+PASS /\7/u threw exception SyntaxError: Invalid regular _expression_: invalid backreference for unicode pattern.
+PASS /\8/u threw exception SyntaxError: Invalid regular _expression_: invalid backreference for unicode pattern.
+PASS /\9/u threw exception SyntaxError: Invalid regular _expression_: invalid backreference for unicode pattern.
+PASS /(.)\1/u did not throw exception.
+PASS /(.)(.)\2/u did not throw exception.
+PASS /(.)(.)\3/u threw exception SyntaxError: Invalid regular _expression_: invalid backreference for unicode pattern.
+PASS /\1/ did not throw exception.
+PASS /\2/ did not throw exception.
+PASS /\3/ did not throw exception.
+PASS /\4/ did not throw exception.
+PASS /\5/ did not throw exception.
+PASS /\6/ did not throw exception.
+PASS /\7/ did not throw exception.
+PASS /\8/ did not throw exception.
+PASS /\9/ did not throw exception.
 PASS successfullyParsed is true
 
 TEST COMPLETE

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


--- trunk/LayoutTests/js/script-tests/regexp-unicode.js	2017-04-13 02:26:53 UTC (rev 215310)
+++ trunk/LayoutTests/js/script-tests/regexp-unicode.js	2017-04-13 02:51:18 UTC (rev 215311)
@@ -220,3 +220,28 @@
 
 shouldThrowInvalidEscape("\\\\u{", '"SyntaxError: Invalid regular _expression_: invalid unicode {} escape"');
 shouldThrowInvalidEscape("\\\\u{\\udead", '"SyntaxError: Invalid regular _expression_: invalid unicode {} escape"');
+
+// Check that invalid backreferences in unicode patterns throw exceptions.
+shouldThrow(`/\\1/u`);
+shouldThrow(`/\\2/u`);
+shouldThrow(`/\\3/u`);
+shouldThrow(`/\\4/u`);
+shouldThrow(`/\\5/u`);
+shouldThrow(`/\\6/u`);
+shouldThrow(`/\\7/u`);
+shouldThrow(`/\\8/u`);
+shouldThrow(`/\\9/u`);
+shouldNotThrow(`/(.)\\1/u`);
+shouldNotThrow(`/(.)(.)\\2/u`);
+shouldThrow(`/(.)(.)\\3/u`);
+
+// Invalid backreferences are okay in non-unicode patterns.
+shouldNotThrow(`/\\1/`);
+shouldNotThrow(`/\\2/`);
+shouldNotThrow(`/\\3/`);
+shouldNotThrow(`/\\4/`);
+shouldNotThrow(`/\\5/`);
+shouldNotThrow(`/\\6/`);
+shouldNotThrow(`/\\7/`);
+shouldNotThrow(`/\\8/`);
+shouldNotThrow(`/\\9/`);

Modified: trunk/Source/_javascript_Core/ChangeLog (215310 => 215311)


--- trunk/Source/_javascript_Core/ChangeLog	2017-04-13 02:26:53 UTC (rev 215310)
+++ trunk/Source/_javascript_Core/ChangeLog	2017-04-13 02:51:18 UTC (rev 215311)
@@ -1,3 +1,18 @@
+2017-04-12  Joseph Pecoraro  <[email protected]>
+
+        test262: test262/test/language/literals/regexp/u-dec-esc.js
+        https://bugs.webkit.org/show_bug.cgi?id=170687
+
+        Reviewed by Michael Saboff.
+
+        * yarr/YarrParser.h:
+        (JSC::Yarr::Parser::parseEscape):
+        * yarr/YarrPattern.cpp:
+        (JSC::Yarr::YarrPattern::errorMessage):
+        (JSC::Yarr::YarrPattern::compile):
+        * yarr/YarrPattern.h:
+        In unicoe patterns, invalid backreferences are an error.
+
 2017-04-12  Filip Pizlo  <[email protected]>
 
         Move common stack allocation utilities out of AirAllocateStackByGraphColoring.cpp

Modified: trunk/Source/_javascript_Core/yarr/YarrParser.h (215310 => 215311)


--- trunk/Source/_javascript_Core/yarr/YarrParser.h	2017-04-13 02:26:53 UTC (rev 215310)
+++ trunk/Source/_javascript_Core/yarr/YarrParser.h	2017-04-13 02:51:18 UTC (rev 215311)
@@ -342,8 +342,13 @@
                 }
 
                 restoreState(state);
+
+                if (m_isUnicode) {
+                    m_err = YarrPattern::InvalidBackreference;
+                    return false;
+                }
             }
-            
+
             // Not a backreference, and not octal. Just a number.
             if (peek() >= '8') {
                 delegate.atomPatternCharacter(consume());

Modified: trunk/Source/_javascript_Core/yarr/YarrPattern.cpp (215310 => 215311)


--- trunk/Source/_javascript_Core/yarr/YarrPattern.cpp	2017-04-13 02:26:53 UTC (rev 215310)
+++ trunk/Source/_javascript_Core/yarr/YarrPattern.cpp	2017-04-13 02:51:18 UTC (rev 215311)
@@ -895,22 +895,23 @@
 #define REGEXP_ERROR_PREFIX "Invalid regular _expression_: "
     // The order of this array must match the ErrorCode enum.
     static const char* errorMessages[NumberOfErrorCodes] = {
-        nullptr, // NoError
-        REGEXP_ERROR_PREFIX "regular _expression_ too large",
-        REGEXP_ERROR_PREFIX "numbers out of order in {} quantifier",
-        REGEXP_ERROR_PREFIX "nothing to repeat",
-        REGEXP_ERROR_PREFIX "number too large in {} quantifier",
-        REGEXP_ERROR_PREFIX "missing )",
-        REGEXP_ERROR_PREFIX "unmatched parentheses",
-        REGEXP_ERROR_PREFIX "unrecognized character after (?",
-        REGEXP_ERROR_PREFIX "missing terminating ] for character class",
-        REGEXP_ERROR_PREFIX "range out of order in character class",
-        REGEXP_ERROR_PREFIX "\\ at end of pattern",
-        REGEXP_ERROR_PREFIX "invalid unicode {} escape",
-        REGEXP_ERROR_PREFIX "invalid escaped character for unicode pattern",
-        REGEXP_ERROR_PREFIX "too many nested disjunctions",
-        REGEXP_ERROR_PREFIX "pattern exceeds string length limits",
-        REGEXP_ERROR_PREFIX "invalid flags"
+        nullptr,                                                              // NoError
+        REGEXP_ERROR_PREFIX "regular _expression_ too large",                   // PatternTooLarge     
+        REGEXP_ERROR_PREFIX "numbers out of order in {} quantifier",          // QuantifierOutOfOrder
+        REGEXP_ERROR_PREFIX "nothing to repeat",                              // QuantifierWithoutAtom
+        REGEXP_ERROR_PREFIX "number too large in {} quantifier",              // QuantifierTooLarge
+        REGEXP_ERROR_PREFIX "missing )",                                      // MissingParentheses
+        REGEXP_ERROR_PREFIX "unmatched parentheses",                          // ParenthesesUnmatched
+        REGEXP_ERROR_PREFIX "unrecognized character after (?",                // ParenthesesTypeInvalid
+        REGEXP_ERROR_PREFIX "missing terminating ] for character class",      // CharacterClassUnmatched
+        REGEXP_ERROR_PREFIX "range out of order in character class",          // CharacterClassOutOfOrder
+        REGEXP_ERROR_PREFIX "\\ at end of pattern",                           // EscapeUnterminated
+        REGEXP_ERROR_PREFIX "invalid unicode {} escape",                      // InvalidUnicodeEscape
+        REGEXP_ERROR_PREFIX "invalid backreference for unicode pattern",      // InvalidBackreference
+        REGEXP_ERROR_PREFIX "invalid escaped character for unicode pattern",  // InvalidIdentityEscape
+        REGEXP_ERROR_PREFIX "too many nested disjunctions",                   // TooManyDisjunctions
+        REGEXP_ERROR_PREFIX "pattern exceeds string length limits",           // OffsetTooLarge
+        REGEXP_ERROR_PREFIX "invalid flags"                                   // InvalidRegularExpressionFlags
     };
 
     return errorMessages[error];
@@ -931,6 +932,9 @@
     //      "Note: if the number of left parentheses is less than the number specified
     //       in \#, the \# is taken as an octal escape as described in the next row."
     if (containsIllegalBackReference()) {
+        if (unicode())
+            return errorMessage(InvalidBackreference);
+
         unsigned numSubpatterns = m_numSubpatterns;
 
         constructor.reset();

Modified: trunk/Source/_javascript_Core/yarr/YarrPattern.h (215310 => 215311)


--- trunk/Source/_javascript_Core/yarr/YarrPattern.h	2017-04-13 02:26:53 UTC (rev 215310)
+++ trunk/Source/_javascript_Core/yarr/YarrPattern.h	2017-04-13 02:51:18 UTC (rev 215311)
@@ -329,6 +329,7 @@
         CharacterClassOutOfOrder,
         EscapeUnterminated,
         InvalidUnicodeEscape,
+        InvalidBackreference,
         InvalidIdentityEscape,
         TooManyDisjunctions,
         OffsetTooLarge,
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to