Skip to content

Commit

Permalink
Merge r222601 - REGRESSION(210837): RegExp containing failed non-zero…
Browse files Browse the repository at this point in the history
… minimum greedy groups incorrectly match

https://bugs.webkit.org/show_bug.cgi?id=177570

Reviewed by Filip Pizlo.

JSTests:

New regression test.

* stress/regress-177570.js: Added.

Source/JavaScriptCore:

The change in r210837 neglected to change the check in Interpreter::backtrackParentheses() that
greedy parenthesis have backtracked as far as possible.  Prior to r210837 when non-zero minimum greedy
parenthesis were factored into a fixed component and then a zero-based variable component.  After
r210837, the variable component is not zero based and the check needs to compare the
backTrack->matchAmount with the quantity iminimum count.

* yarr/YarrInterpreter.cpp:
(JSC::Yarr::Interpreter::backtrackParentheses):
  • Loading branch information
msaboff authored and carlosgcampos committed Oct 17, 2017
1 parent dff69bc commit 1d8ac29
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
11 changes: 11 additions & 0 deletions JSTests/ChangeLog
@@ -1,3 +1,14 @@
2017-09-27 Michael Saboff <msaboff@apple.com>

REGRESSION(210837): RegExp containing failed non-zero minimum greedy groups incorrectly match
https://bugs.webkit.org/show_bug.cgi?id=177570

Reviewed by Filip Pizlo.

New regression test.

* stress/regress-177570.js: Added.

2017-09-27 Mark Lam <mark.lam@apple.com>

JSArray::canFastCopy() should fail if the source and destination arrays are the same.
Expand Down
4 changes: 4 additions & 0 deletions JSTests/stress/regress-177570.js
@@ -0,0 +1,4 @@
// Regression test for bug 177570

if (/(Q)+|(\S)+Z/.test("Z "))
throw "/(Q)+|(\S)+Z/.test(\"Z \") should fail, but actually succeeds";
16 changes: 16 additions & 0 deletions Source/JavaScriptCore/ChangeLog
@@ -1,3 +1,19 @@
2017-09-27 Michael Saboff <msaboff@apple.com>

REGRESSION(210837): RegExp containing failed non-zero minimum greedy groups incorrectly match
https://bugs.webkit.org/show_bug.cgi?id=177570

Reviewed by Filip Pizlo.

The change in r210837 neglected to change the check in Interpreter::backtrackParentheses() that
greedy parenthesis have backtracked as far as possible. Prior to r210837 when non-zero minimum greedy
parenthesis were factored into a fixed component and then a zero-based variable component. After
r210837, the variable component is not zero based and the check needs to compare the
backTrack->matchAmount with the quantity iminimum count.

* yarr/YarrInterpreter.cpp:
(JSC::Yarr::Interpreter::backtrackParentheses):

2017-09-27 Mark Lam <mark.lam@apple.com>

JSArray::canFastCopy() should fail if the source and destination arrays are the same.
Expand Down
2 changes: 1 addition & 1 deletion Source/JavaScriptCore/yarr/YarrInterpreter.cpp
Expand Up @@ -1056,7 +1056,7 @@ class Interpreter {
}

case QuantifierGreedy: {
if (!backTrack->matchAmount)
if (backTrack->matchAmount == term.atom.quantityMinCount)
return JSRegExpNoMatch;

ParenthesesDisjunctionContext* context = backTrack->lastContext;
Expand Down

0 comments on commit 1d8ac29

Please sign in to comment.