Diff
Modified: trunk/JSTests/ChangeLog (255451 => 255452)
--- trunk/JSTests/ChangeLog 2020-01-30 21:17:43 UTC (rev 255451)
+++ trunk/JSTests/ChangeLog 2020-01-30 21:27:11 UTC (rev 255452)
@@ -1,3 +1,16 @@
+2020-01-30 Alexey Shvayka <[email protected]>
+
+ Incomplete braced quantifiers should be banned in Unicode patterns only
+ https://bugs.webkit.org/show_bug.cgi?id=206776
+
+ Reviewed by Darin Adler.
+
+ 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.
+
2020-01-30 Keith Miller <[email protected]>
Parser needs to restore unary stack state when backtracking
@@ -85,7 +98,7 @@
2020-01-26 Alexey Shvayka <[email protected]>
- Invalid ranges in character classes should be banned in unicode patterns
+ Invalid ranges in character classes should be banned in Unicode patterns only
https://bugs.webkit.org/show_bug.cgi?id=206768
Reviewed by Darin Adler.
Modified: trunk/JSTests/test262/expectations.yaml (255451 => 255452)
--- trunk/JSTests/test262/expectations.yaml 2020-01-30 21:17:43 UTC (rev 255451)
+++ trunk/JSTests/test262/expectations.yaml 2020-01-30 21:27:11 UTC (rev 255452)
@@ -11,9 +11,6 @@
test/annexB/built-ins/RegExp/prototype/Symbol.split/Symbol.match-getter-recompiles-source.js:
default: 'Test262Error: Expected SameValue(«», «a») to be true'
strict mode: 'Test262Error: Expected SameValue(«», «a») to be true'
-test/annexB/built-ins/RegExp/prototype/compile/pattern-string-invalid-u.js:
- default: 'Test262Error: invalid pattern: { Expected a SyntaxError to be thrown but no exception was thrown at all'
- strict mode: 'Test262Error: invalid pattern: { Expected a SyntaxError to be thrown but no exception was thrown at all'
test/annexB/language/eval-code/direct/func-block-decl-eval-func-skip-early-err-block.js:
default: 'Test262Error: An initialized binding is not created prior to evaluation Expected a ReferenceError to be thrown but no exception was thrown at all'
test/annexB/language/eval-code/direct/func-block-decl-eval-func-skip-early-err-for-in.js:
@@ -1519,24 +1516,6 @@
test/built-ins/RegExp/property-escapes/generated/XID_Start.js:
default: 'Test262Error: `\p{XID_Start}` should match U+001CFA (`ᳺ`)'
strict mode: 'Test262Error: `\p{XID_Start}` should match U+001CFA (`ᳺ`)'
-test/built-ins/RegExp/property-escapes/non-existent-property-value-General_Category-negated.js:
- default: 'Test262: This statement should not be evaluated.'
- strict mode: 'Test262: This statement should not be evaluated.'
-test/built-ins/RegExp/property-escapes/non-existent-property-value-Script-negated.js:
- default: 'Test262: This statement should not be evaluated.'
- strict mode: 'Test262: This statement should not be evaluated.'
-test/built-ins/RegExp/property-escapes/non-existent-property-value-Script.js:
- default: 'Test262: This statement should not be evaluated.'
- strict mode: 'Test262: This statement should not be evaluated.'
-test/built-ins/RegExp/property-escapes/non-existent-property-value-Script_Extensions-negated.js:
- default: 'Test262: This statement should not be evaluated.'
- strict mode: 'Test262: This statement should not be evaluated.'
-test/built-ins/RegExp/property-escapes/non-existent-property-value-Script_Extensions.js:
- default: 'Test262: This statement should not be evaluated.'
- strict mode: 'Test262: This statement should not be evaluated.'
-test/built-ins/RegExp/property-escapes/non-existent-property-value-general-category.js:
- default: 'Test262: This statement should not be evaluated.'
- strict mode: 'Test262: This statement should not be evaluated.'
test/built-ins/RegExp/proto-from-ctor-realm.js:
default: 'Test262Error: Expected SameValue(«/(?:)/», «/(?:)/») to be true'
strict mode: 'Test262Error: Expected SameValue(«/(?:)/», «/(?:)/») to be true'
@@ -1606,9 +1585,6 @@
test/built-ins/RegExp/unicode_restricted_identity_escape_c.js:
default: 'Test262Error: Expected a SyntaxError to be thrown but no exception was thrown at all'
strict mode: 'Test262Error: Expected a SyntaxError to be thrown but no exception was thrown at all'
-test/built-ins/RegExp/unicode_restricted_incomple_quantifier.js:
- default: 'Test262Error: RegExp("a{", "u"): Expected a SyntaxError to be thrown but no exception was thrown at all'
- strict mode: 'Test262Error: RegExp("a{", "u"): Expected a SyntaxError to be thrown but no exception was thrown at all'
test/built-ins/RegExp/unicode_restricted_octal_escape.js:
default: 'Test262Error: RegExp("[\1]", "u"): Expected a SyntaxError to be thrown but no exception was thrown at all'
strict mode: 'Test262Error: RegExp("[\1]", "u"): Expected a SyntaxError to be thrown but no exception was thrown at all'
@@ -3402,9 +3378,6 @@
test/language/literals/regexp/u-invalid-class-escape.js:
default: 'Test262: This statement should not be evaluated.'
strict mode: 'Test262: This statement should not be evaluated.'
-test/language/literals/regexp/u-invalid-extended-pattern-char.js:
- default: 'Test262: This statement should not be evaluated.'
- strict mode: 'Test262: This statement should not be evaluated.'
test/language/literals/regexp/u-invalid-legacy-octal-escape.js:
default: 'Test262: This statement should not be evaluated.'
strict mode: 'Test262: This statement should not be evaluated.'
Modified: trunk/LayoutTests/ChangeLog (255451 => 255452)
--- trunk/LayoutTests/ChangeLog 2020-01-30 21:17:43 UTC (rev 255451)
+++ trunk/LayoutTests/ChangeLog 2020-01-30 21:27:11 UTC (rev 255452)
@@ -1,3 +1,19 @@
+2020-01-30 Alexey Shvayka <[email protected]>
+
+ Incomplete braced quantifiers should be banned in Unicode patterns only
+ https://bugs.webkit.org/show_bug.cgi?id=206776
+
+ Reviewed by Darin Adler.
+
+ 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:
+
2020-01-30 Doug Kelly <[email protected]>
Crash in RenderElement::selectionPseudoStyle with detail element set to display: contents
Modified: trunk/LayoutTests/js/regexp-named-capture-groups-expected.txt (255451 => 255452)
--- trunk/LayoutTests/js/regexp-named-capture-groups-expected.txt 2020-01-30 21:17:43 UTC (rev 255451)
+++ trunk/LayoutTests/js/regexp-named-capture-groups-expected.txt 2020-01-30 21:27:11 UTC (rev 255452)
@@ -49,9 +49,9 @@
PASS "Give me a \'k\'!".match(/Give me a \'\k\'/)[0] is "Give me a \'k\'"
PASS "Give me \'k2\'!".match(/Give me \'\k2\'/)[0] is "Give me \'k2\'"
PASS "Give me a \'kat\'!".match(/Give me a \'\kat\'/)[0] is "Give me a \'kat\'"
-PASS "Give me a \'k\'!".match(/Give me a \'\k\'/u)[0] threw exception SyntaxError: Invalid regular _expression_: invalid escaped character for unicode pattern.
-PASS "Give me \'k2\'!".match(/Give me \'\k2\'/u)[0] threw exception SyntaxError: Invalid regular _expression_: invalid escaped character for unicode pattern.
-PASS "Give me a \'kat\'!".match(/Give me a \'\kat\'/u)[0] threw exception SyntaxError: Invalid regular _expression_: invalid escaped character for unicode pattern.
+PASS "Give me a \'k\'!".match(/Give me a \'\k\'/u)[0] threw exception SyntaxError: Invalid regular _expression_: invalid escaped character for Unicode pattern.
+PASS "Give me \'k2\'!".match(/Give me \'\k2\'/u)[0] threw exception SyntaxError: Invalid regular _expression_: invalid escaped character for Unicode pattern.
+PASS "Give me a \'kat\'!".match(/Give me a \'\kat\'/u)[0] threw exception SyntaxError: Invalid regular _expression_: invalid escaped character for Unicode pattern.
PASS "10/20/1930".replace(/(?<month>\d{2})\/(?<day>\d{2})\/(?<year>\d{4})/, "$<day>-$<mouth>-$<year>") is "20--1930"
PASS "10/20/1930".replace(/(?<month>\d{2})\/(?<day>\d{2})\/(?<year>\d{4})/, "$<day>-$<month>-$<year") is "20-10-$<year"
PASS let r = new RegExp("/(?<groupName1>abc)|(?<groupName1>def)/") threw exception SyntaxError: Invalid regular _expression_: duplicate group specifier name.
@@ -66,7 +66,7 @@
PASS "1122332211".match(/\k<ones>\k<twos>\k<threes>(?<ones>1*)(?<twos>2*)(?<threes>3*)\k<threes>\k<twos>\k<ones>/) is ["1122332211", "11", "22", "3"]
PASS "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"]
PASS "\k<z>XzzX".match(/\k<z>X(z*)X/) is ["k<z>XzzX", "zz"]
-PASS "\k<z>XzzX".match(/\k<z>X(z*)X/u) threw exception SyntaxError: Invalid regular _expression_: invalid backreference for unicode pattern.
+PASS "\k<z>XzzX".match(/\k<z>X(z*)X/u) threw exception SyntaxError: Invalid regular _expression_: invalid backreference for Unicode pattern.
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/js/regexp-unicode-expected.txt (255451 => 255452)
--- trunk/LayoutTests/js/regexp-unicode-expected.txt 2020-01-30 21:17:43 UTC (rev 255451)
+++ trunk/LayoutTests/js/regexp-unicode-expected.txt 2020-01-30 21:27:11 UTC (rev 255452)
@@ -163,31 +163,33 @@
PASS "Testing 𐃰\n1 2 3".match(/g [က-]$\n1/um)[0] is "g 𐃰\n1"
PASS "this is ba test".match(/is b\cha test/u)[0].length is 11
PASS new RegExp("\\/", "u").source is "\\/"
-PASS r = new RegExp("\\u{110000}", "u") threw exception SyntaxError: Invalid regular _expression_: invalid unicode {} escape.
+PASS r = new RegExp("\\u{110000}", "u") threw exception SyntaxError: Invalid regular _expression_: invalid Unicode {} escape.
PASS r = new RegExp("𐐅{2147483648}", "u") threw exception SyntaxError: Invalid regular _expression_: pattern exceeds string length limits.
-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.
-PASS r = new RegExp("[\\b]", "u") threw exception SyntaxError: Invalid regular _expression_: invalid escaped character for unicode pattern.
-PASS r = new RegExp("[\\B]", "u") threw exception SyntaxError: Invalid regular _expression_: invalid escaped character for unicode pattern.
-PASS r = new RegExp("\\x", "u") threw exception SyntaxError: Invalid regular _expression_: invalid escaped character for unicode pattern.
-PASS r = new RegExp("[\\x]", "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 escaped character for unicode pattern.
-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 /{/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 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.
+PASS r = new RegExp("[\\b]", "u") threw exception SyntaxError: Invalid regular _expression_: invalid escaped character for Unicode pattern.
+PASS r = new RegExp("[\\B]", "u") threw exception SyntaxError: Invalid regular _expression_: invalid escaped character for Unicode pattern.
+PASS r = new RegExp("\\x", "u") threw exception SyntaxError: Invalid regular _expression_: invalid escaped character for Unicode pattern.
+PASS r = new RegExp("[\\x]", "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 escaped character for Unicode pattern.
+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 /(.)(.)\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.
Modified: trunk/LayoutTests/js/regress-158080-expected.txt (255451 => 255452)
--- trunk/LayoutTests/js/regress-158080-expected.txt 2020-01-30 21:17:43 UTC (rev 255451)
+++ trunk/LayoutTests/js/regress-158080-expected.txt 2020-01-30 21:27:11 UTC (rev 255452)
@@ -3,17 +3,17 @@
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-PASS let r = /\u{|abc/u threw exception SyntaxError: Invalid regular _expression_: invalid unicode {} escape.
-PASS let r = /\u{/u threw exception SyntaxError: Invalid regular _expression_: invalid unicode {} escape.
-PASS let r = /\u{1/u threw exception SyntaxError: Invalid regular _expression_: invalid unicode {} escape.
-PASS let r = /\u{12/u threw exception SyntaxError: Invalid regular _expression_: invalid unicode {} escape.
-PASS let r = /\u{123/u threw exception SyntaxError: Invalid regular _expression_: invalid unicode {} escape.
-PASS let r = /\u{1234/u threw exception SyntaxError: Invalid regular _expression_: invalid unicode {} escape.
-PASS let r = /\u{abcde/u threw exception SyntaxError: Invalid regular _expression_: invalid unicode {} escape.
-PASS let r = /\u{abcdef/u threw exception SyntaxError: Invalid regular _expression_: invalid unicode {} escape.
-PASS let r = /\u{1111111}/u threw exception SyntaxError: Invalid regular _expression_: invalid unicode {} escape.
-PASS let r = /\u{fedbca98}/u threw exception SyntaxError: Invalid regular _expression_: invalid unicode {} escape.
-PASS let r = /\u{1{123}}/u threw exception SyntaxError: Invalid regular _expression_: invalid unicode {} escape.
+PASS let r = /\u{|abc/u threw exception SyntaxError: Invalid regular _expression_: invalid Unicode {} escape.
+PASS let r = /\u{/u threw exception SyntaxError: Invalid regular _expression_: invalid Unicode {} escape.
+PASS let r = /\u{1/u threw exception SyntaxError: Invalid regular _expression_: invalid Unicode {} escape.
+PASS let r = /\u{12/u threw exception SyntaxError: Invalid regular _expression_: invalid Unicode {} escape.
+PASS let r = /\u{123/u threw exception SyntaxError: Invalid regular _expression_: invalid Unicode {} escape.
+PASS let r = /\u{1234/u threw exception SyntaxError: Invalid regular _expression_: invalid Unicode {} escape.
+PASS let r = /\u{abcde/u threw exception SyntaxError: Invalid regular _expression_: invalid Unicode {} escape.
+PASS let r = /\u{abcdef/u threw exception SyntaxError: Invalid regular _expression_: invalid Unicode {} escape.
+PASS let r = /\u{1111111}/u threw exception SyntaxError: Invalid regular _expression_: invalid Unicode {} escape.
+PASS let r = /\u{fedbca98}/u threw exception SyntaxError: Invalid regular _expression_: invalid Unicode {} escape.
+PASS let r = /\u{1{123}}/u threw exception SyntaxError: Invalid regular _expression_: invalid Unicode {} escape.
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/js/script-tests/regexp-named-capture-groups.js (255451 => 255452)
--- trunk/LayoutTests/js/script-tests/regexp-named-capture-groups.js 2020-01-30 21:17:43 UTC (rev 255451)
+++ trunk/LayoutTests/js/script-tests/regexp-named-capture-groups.js 2020-01-30 21:27:11 UTC (rev 255452)
@@ -85,9 +85,9 @@
shouldBe('"Give me \\\'k2\\\'!".match(/Give me \\\'\\\k2\\\'/)[0]', '"Give me \\\'k2\\\'"');
shouldBe('"Give me a \\\'kat\\\'!".match(/Give me a \\\'\\\kat\\\'/)[0]', '"Give me a \\\'kat\\\'"');
// Verify that named back references for non-existing named group matches the k<groupName> throw for unicode patterns.
-shouldThrow('"Give me a \\\'k\\\'!".match(/Give me a \\\'\\\k\\\'/u)[0]', '"SyntaxError: Invalid regular _expression_: invalid escaped character for unicode pattern"');
-shouldThrow('"Give me \\\'k2\\\'!".match(/Give me \\\'\\\k2\\\'/u)[0]', '"SyntaxError: Invalid regular _expression_: invalid escaped character for unicode pattern"');
-shouldThrow('"Give me a \\\'kat\\\'!".match(/Give me a \\\'\\\kat\\\'/u)[0]', '"SyntaxError: Invalid regular _expression_: invalid escaped character for unicode pattern"');
+shouldThrow('"Give me a \\\'k\\\'!".match(/Give me a \\\'\\\k\\\'/u)[0]', '"SyntaxError: Invalid regular _expression_: invalid escaped character for Unicode pattern"');
+shouldThrow('"Give me \\\'k2\\\'!".match(/Give me \\\'\\\k2\\\'/u)[0]', '"SyntaxError: Invalid regular _expression_: invalid escaped character for Unicode pattern"');
+shouldThrow('"Give me a \\\'kat\\\'!".match(/Give me a \\\'\\\kat\\\'/u)[0]', '"SyntaxError: Invalid regular _expression_: invalid escaped character for Unicode pattern"');
// Check invalid group name specifiers in a replace string.
shouldBe('"10/20/1930".replace(/(?<month>\\d{2})\\\/(?<day>\\d{2})\\\/(?<year>\\d{4})/, "$<day>-$<mouth>-$<year>")', '"20--1930"');
@@ -113,4 +113,4 @@
// Check that a named forward reference for a non-existent named capture
// matches for non-unicode patterns and throws for unicode patterns.
shouldBe('"\\\k<z>XzzX".match(/\\\k<z>X(z*)X/)', '["k<z>XzzX", "zz"]');
-shouldThrow('"\\\k<z>XzzX".match(/\\\k<z>X(z*)X/u)', '"SyntaxError: Invalid regular _expression_: invalid backreference for unicode pattern"');
+shouldThrow('"\\\k<z>XzzX".match(/\\\k<z>X(z*)X/u)', '"SyntaxError: Invalid regular _expression_: invalid backreference for Unicode pattern"');
Modified: trunk/LayoutTests/js/script-tests/regexp-unicode.js (255451 => 255452)
--- trunk/LayoutTests/js/script-tests/regexp-unicode.js 2020-01-30 21:17:43 UTC (rev 255451)
+++ trunk/LayoutTests/js/script-tests/regexp-unicode.js 2020-01-30 21:27:11 UTC (rev 255452)
@@ -228,10 +228,12 @@
// Check that invalid unicode patterns throw exceptions
shouldBe('new RegExp("\\\\/", "u").source', '"\\\\/"');
-shouldThrow('r = new RegExp("\\\\u{110000}", "u")', '"SyntaxError: Invalid regular _expression_: invalid unicode {} escape"');
+shouldThrow('r = new RegExp("\\\\u{110000}", "u")', '"SyntaxError: Invalid regular _expression_: invalid Unicode {} escape"');
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"');
-var invalidEscapeException = "SyntaxError: Invalid regular _expression_: invalid escaped character for unicode pattern";
+var invalidEscapeException = "SyntaxError: Invalid regular _expression_: invalid escaped character for Unicode pattern";
var newRegExp;
function shouldThrowInvalidEscape(pattern, error='invalidEscapeException')
@@ -251,8 +253,8 @@
shouldThrowInvalidEscape("\\\\u");
shouldThrowInvalidEscape("[\\\\u]");
-shouldThrowInvalidEscape("\\\\u{", '"SyntaxError: Invalid regular _expression_: invalid unicode {} escape"');
-shouldThrowInvalidEscape("\\\\u{\\udead", '"SyntaxError: Invalid regular _expression_: invalid unicode {} escape"');
+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`);
Modified: trunk/Source/_javascript_Core/ChangeLog (255451 => 255452)
--- trunk/Source/_javascript_Core/ChangeLog 2020-01-30 21:17:43 UTC (rev 255451)
+++ trunk/Source/_javascript_Core/ChangeLog 2020-01-30 21:27:11 UTC (rev 255452)
@@ -1,3 +1,23 @@
+2020-01-30 Alexey Shvayka <[email protected]>
+
+ Incomplete braced quantifiers should be banned in Unicode patterns only
+ https://bugs.webkit.org/show_bug.cgi?id=206776
+
+ Reviewed by Darin Adler.
+
+ 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):
+
2020-01-30 Yusuke Suzuki <[email protected]>
[JSC] Make SourceProviderCacheItem small
@@ -380,7 +400,7 @@
2020-01-26 Alexey Shvayka <[email protected]>
- Invalid ranges in character classes should be banned in unicode patterns
+ Invalid ranges in character classes should be banned in Unicode patterns only
https://bugs.webkit.org/show_bug.cgi?id=206768
Reviewed by Darin Adler.
@@ -387,10 +407,10 @@
In ES5, grammar of CharacterRange was ambiguous, resulting in invalid ranges
like /[\d-a]/ being allowed. As of ES2015, invalid ranges are SyntaxError in
- unicode patterns, yet still allowed in regular ones to avoid breaking the web.
+ Unicode patterns, yet still allowed in regular ones to avoid breaking the web.
(https://tc39.es/ecma262/#sec-patterns-static-semantics-early-errors-annexb)
- This change adds SyntaxError for unicode patterns and updates explanatory
+ This change adds SyntaxError for Unicode patterns and updates explanatory
comments. ErrorCode::CharacterClassOutOfOrder is renamed for consistency
with newly added error code and ErrorCode::ParenthesesTypeInvalid.
Modified: trunk/Source/_javascript_Core/yarr/YarrErrorCode.cpp (255451 => 255452)
--- trunk/Source/_javascript_Core/yarr/YarrErrorCode.cpp 2020-01-30 21:17:43 UTC (rev 255451)
+++ trunk/Source/_javascript_Core/yarr/YarrErrorCode.cpp 2020-01-30 21:27:11 UTC (rev 255452)
@@ -40,6 +40,7 @@
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 "incomplete {} quantifier for Unicode pattern", // QuantifierIncomplete
REGEXP_ERROR_PREFIX "missing )", // MissingParentheses
REGEXP_ERROR_PREFIX "unmatched parentheses", // ParenthesesUnmatched
REGEXP_ERROR_PREFIX "unrecognized character after (?", // ParenthesesTypeInvalid
@@ -47,11 +48,11 @@
REGEXP_ERROR_PREFIX "duplicate group specifier name", // DuplicateGroupName
REGEXP_ERROR_PREFIX "missing terminating ] for character class", // CharacterClassUnmatched
REGEXP_ERROR_PREFIX "range out of order in character class", // CharacterClassRangeOutOfOrder
- REGEXP_ERROR_PREFIX "invalid range in character class for unicode pattern", // CharacterClassRangeInvalid
+ REGEXP_ERROR_PREFIX "invalid range in character class for Unicode pattern", // CharacterClassRangeInvalid
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 "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 "invalid property _expression_", // InvalidUnicodePropertyExpression
REGEXP_ERROR_PREFIX "too many nested disjunctions", // TooManyDisjunctions
REGEXP_ERROR_PREFIX "pattern exceeds string length limits", // OffsetTooLarge
@@ -71,6 +72,7 @@
case ErrorCode::QuantifierOutOfOrder:
case ErrorCode::QuantifierWithoutAtom:
case ErrorCode::QuantifierTooLarge:
+ case ErrorCode::QuantifierIncomplete:
case ErrorCode::MissingParentheses:
case ErrorCode::ParenthesesUnmatched:
case ErrorCode::ParenthesesTypeInvalid:
Modified: trunk/Source/_javascript_Core/yarr/YarrErrorCode.h (255451 => 255452)
--- trunk/Source/_javascript_Core/yarr/YarrErrorCode.h 2020-01-30 21:17:43 UTC (rev 255451)
+++ trunk/Source/_javascript_Core/yarr/YarrErrorCode.h 2020-01-30 21:27:11 UTC (rev 255452)
@@ -39,6 +39,7 @@
QuantifierOutOfOrder,
QuantifierWithoutAtom,
QuantifierTooLarge,
+ QuantifierIncomplete,
MissingParentheses,
ParenthesesUnmatched,
ParenthesesTypeInvalid,
Modified: trunk/Source/_javascript_Core/yarr/YarrParser.h (255451 => 255452)
--- trunk/Source/_javascript_Core/yarr/YarrParser.h 2020-01-30 21:17:43 UTC (rev 255451)
+++ trunk/Source/_javascript_Core/yarr/YarrParser.h 2020-01-30 21:27:11 UTC (rev 255452)
@@ -817,10 +817,15 @@
}
}
+ if (m_isUnicode) {
+ m_errorCode = ErrorCode::QuantifierIncomplete;
+ break;
+ }
+
restoreState(state);
+ // if we did not find a complete quantifer, fall through to the default case.
+ FALLTHROUGH;
}
- // if we did not find a complete quantifer, fall through to the default case.
- FALLTHROUGH;
default:
m_delegate.atomPatternCharacter(consumePossibleSurrogatePair());