2011-01-18 Michael Saboff <msaboff@apple.com>
authormsaboff@apple.com <msaboff@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Jan 2011 23:31:30 +0000 (23:31 +0000)
committermsaboff@apple.com <msaboff@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Jan 2011 23:31:30 +0000 (23:31 +0000)
        Reviewed by Oliver Hunt.

        <rdar://problem/8875432> Regression: Some text-only e-mails cause hang beneath RegExp::match (52540)
        https://bugs.webkit.org/show_bug.cgi?id=52540
        https://bugs.webkit.org/show_bug.cgi?id=52662

        Directly use backtrack label with parentheses nested under a
        non-capturing parentheses.  Also linked current parentheses
        tail code object for possible parens nested within a non-capturing
        parentheses.

        * yarr/YarrJIT.cpp:
        (JSC::Yarr::YarrGenerator::BacktrackDestination::linkBacktrackToLabel):
        (JSC::Yarr::YarrGenerator::generateParenthesesSingle):
2011-01-18  Michael Saboff  <msaboff@apple.com>

        Reviewed by Oliver Hunt.

        <rdar://problem/8875432> Regression: Some text-only e-mails cause hang beneath RegExp::match (52540)
        https://bugs.webkit.org/show_bug.cgi?id=52540
        https://bugs.webkit.org/show_bug.cgi?id=52662

        New tests to check for proper linking of parentheses nested under
        a non-capturing parentheses.

        * fast/regex/parentheses-expected.txt:
        * fast/regex/script-tests/parentheses.js:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@76076 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/regex/parentheses-expected.txt
LayoutTests/fast/regex/script-tests/parentheses.js
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/yarr/YarrJIT.cpp

index 64f751e..322aa83 100644 (file)
@@ -1,3 +1,17 @@
+2011-01-18  Michael Saboff  <msaboff@apple.com>
+
+        Reviewed by Oliver Hunt.
+
+        <rdar://problem/8875432> Regression: Some text-only e-mails cause hang beneath RegExp::match (52540)
+        https://bugs.webkit.org/show_bug.cgi?id=52540
+        https://bugs.webkit.org/show_bug.cgi?id=52662
+
+        New tests to check for proper linking of parentheses nested under
+        a non-capturing parentheses.
+
+        * fast/regex/parentheses-expected.txt:
+        * fast/regex/script-tests/parentheses.js:
+
 2011-01-18  David Hyatt  <hyatt@apple.com>
 
         Reviewed by Dan Bernstein.
index 6ec0df4..d526b10 100644 (file)
@@ -67,6 +67,10 @@ PASS regexp40.exec('zPz') is ['',undefined,undefined,undefined,'']
 PASS regexp40.exec('zPPz') is ['',undefined,undefined,undefined,'']
 PASS regexp40.exec('zPPPz') is ['',undefined,undefined,undefined,'']
 PASS regexp40.exec('zPPPPz') is ['',undefined,undefined,undefined,'']
+PASS regexp41.exec('Here is a link: http://www.acme.com/our_products/index.html. That is all we want!') is ['http://www.acme.com/our_products/index.html','http://www.acme.com/our_products/index.html','http://','l',undefined]
+PASS regexp42.exec('') is ['',undefined,undefined]
+PASS regexp42.exec('4') is ['4','4','4']
+PASS regexp42.exec('4321') is ['4','4','4']
 PASS /(?!(?=r{0}){2,})|((z)?)?/gi.test('') is true
 PASS 'Hi Bob'.match(/(Rob)|(Bob)|(Robert)|(Bobby)/) is ['Bob',undefined,'Bob',undefined,undefined]
 PASS successfullyParsed is true
index 3b98b49..db4bf13 100644 (file)
@@ -183,6 +183,14 @@ shouldBe("regexp40.exec('zPPz')", "['',undefined,undefined,undefined,'']");
 shouldBe("regexp40.exec('zPPPz')", "['',undefined,undefined,undefined,'']");
 shouldBe("regexp40.exec('zPPPPz')", "['',undefined,undefined,undefined,'']");
 
+var regexp41 = /(([\w\-]+:\/\/?|www[.])[^\s()<>]+(?:([\w\d]+)|([^\[:punct:\]\s()<>\W]|\/)))/;
+shouldBe("regexp41.exec('Here is a link: http://www.acme.com/our_products/index.html. That is all we want!')", "['http://www.acme.com/our_products/index.html','http://www.acme.com/our_products/index.html','http://','l',undefined]");
+
+var regexp42 = /((?:(4)?))?/;
+shouldBe("regexp42.exec('')", "['',undefined,undefined]");
+shouldBe("regexp42.exec('4')", "['4','4','4']");
+shouldBe("regexp42.exec('4321')", "['4','4','4']");
+
 shouldBeTrue("/(?!(?=r{0}){2,})|((z)?)?/gi.test('')");
 
 shouldBe("'Hi Bob'.match(/(Rob)|(Bob)|(Robert)|(Bobby)/)", "['Bob',undefined,'Bob',undefined,undefined]");
index 3e53e96..e95b1b2 100644 (file)
@@ -1,3 +1,20 @@
+2011-01-18  Michael Saboff  <msaboff@apple.com>
+
+        Reviewed by Oliver Hunt.
+
+        <rdar://problem/8875432> Regression: Some text-only e-mails cause hang beneath RegExp::match (52540)
+        https://bugs.webkit.org/show_bug.cgi?id=52540
+        https://bugs.webkit.org/show_bug.cgi?id=52662
+
+        Directly use backtrack label with parentheses nested under a
+        non-capturing parentheses.  Also linked current parentheses
+        tail code object for possible parens nested within a non-capturing
+        parentheses.
+
+        * yarr/YarrJIT.cpp:
+        (JSC::Yarr::YarrGenerator::BacktrackDestination::linkBacktrackToLabel):
+        (JSC::Yarr::YarrGenerator::generateParenthesesSingle):
+
 2011-01-18  Daniel Bates  <dbates@rim.com>
 
         Reviewed by Gavin Barraclough.
index ae59cba..491d46d 100644 (file)
@@ -748,6 +748,12 @@ class YarrGenerator : private MacroAssembler {
             return false;
         }
 
+        void linkBacktrackToLabel(Label backtrackLabel)
+        {
+            if (m_backtrackToLabel)
+                *m_backtrackToLabel = backtrackLabel;
+        }
+
         void linkAlternativeBacktracks(YarrGenerator* generator, bool nextIteration = false)
         {
             Label hereLabel = generator->label();
@@ -1007,7 +1013,6 @@ class YarrGenerator : private MacroAssembler {
         BacktrackDestination m_backtrack;
         BacktrackDestination* m_linkedBacktrack;
         ParenthesesTail* m_parenthesesTail;
-
     };
 
     struct ParenthesesTail {
@@ -1638,13 +1643,24 @@ class YarrGenerator : private MacroAssembler {
             m_expressionState.incrementParenNestingLevel();
 
             TermGenerationState parenthesesState(disjunction, state.checkedTotal);
+            
+            // Use the current paren Tail to connect the nested parentheses.
+            parenthesesState.setParenthesesTail(state.getParenthesesTail());
+
             generateParenthesesDisjunction(state.term(), parenthesesState, alternativeFrameLocation);
             // this expects that any backtracks back out of the parentheses will be in the
             // parenthesesState's m_backTrackJumps vector, and that if they need backtracking
             // they will have set an entry point on the parenthesesState's m_backtrackLabel.
             BacktrackDestination& parenthesesBacktrack = parenthesesState.getBacktrackDestination();
-            state.propagateBacktrackingFrom(this, parenthesesBacktrack);
-            state.getBacktrackDestination().copyBacktrackToLabel(parenthesesBacktrack);
+            BacktrackDestination& stateBacktrack = state.getBacktrackDestination();
+
+            // If we have a backtrack label, use it for the parenthesis
+            if (stateBacktrack.isLabel())
+                parenthesesBacktrack.linkBacktrackToLabel(stateBacktrack.getLabel());
+            else {
+                state.propagateBacktrackingFrom(this, parenthesesBacktrack);
+                stateBacktrack.copyBacktrackToLabel(parenthesesBacktrack);
+            }
 
             m_expressionState.decrementParenNestingLevel();
         } else {