Title: [90247] trunk
Revision
90247
Author
[email protected]
Date
2011-07-01 11:19:17 -0700 (Fri, 01 Jul 2011)

Log Message

https://bugs.webkit.org/show_bug.cgi?id=63819
Escaping of forwardslashes in strings incorrect if multiple exist.

Reviewed by Sam Weinig.

Source/_javascript_Core: 

The bug is in the parameters passed to a substring - should be
start & length, but we're passing start & end indices!

* runtime/RegExpObject.cpp:
(JSC::regExpObjectSource):

LayoutTests: 

Add tests with multiple forward slashes.

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

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (90246 => 90247)


--- trunk/LayoutTests/ChangeLog	2011-07-01 18:14:37 UTC (rev 90246)
+++ trunk/LayoutTests/ChangeLog	2011-07-01 18:19:17 UTC (rev 90247)
@@ -1,3 +1,15 @@
+2011-07-01  Gavin Barraclough  <[email protected]>
+
+        Reviewed by Sam Weinig.
+
+        https://bugs.webkit.org/show_bug.cgi?id=63819
+        Escaping of forwardslashes in strings incorrect if multiple exist.
+
+        Add tests with multiple forward slashes.
+
+        * fast/regex/script-tests/toString.js:
+        * fast/regex/toString-expected.txt:
+
 2011-07-01  Mihai Parparita  <[email protected]>
 
         Add failing test expectations for Chromium media tests on Windows 7 and

Modified: trunk/LayoutTests/fast/regex/script-tests/toString.js (90246 => 90247)


--- trunk/LayoutTests/fast/regex/script-tests/toString.js	2011-07-01 18:14:37 UTC (rev 90246)
+++ trunk/LayoutTests/fast/regex/script-tests/toString.js	2011-07-01 18:19:17 UTC (rev 90247)
@@ -29,6 +29,11 @@
 // These strings match two backslashes (the second with the '/' escaped).
 shouldBeTrue('testForwardSlash("^\\\\\\\\/$", "\\\\/");');
 shouldBeTrue('testForwardSlash("^\\\\\\\\\\/$", "\\\\/");');
+// Test that nothing goes wrongif there are multiple forward slashes!
+shouldBeTrue('testForwardSlash("x/x/x", "x\\/x\\/x");');
+shouldBeTrue('testForwardSlash("x\\/x/x", "x\\/x\\/x");');
+shouldBeTrue('testForwardSlash("x/x\\/x", "x\\/x\\/x");');
+shouldBeTrue('testForwardSlash("x\\/x\\/x", "x\\/x\\/x");');
 
 var successfullyParsed = true;
 

Modified: trunk/LayoutTests/fast/regex/toString-expected.txt (90246 => 90247)


--- trunk/LayoutTests/fast/regex/toString-expected.txt	2011-07-01 18:14:37 UTC (rev 90246)
+++ trunk/LayoutTests/fast/regex/toString-expected.txt	2011-07-01 18:19:17 UTC (rev 90247)
@@ -16,6 +16,10 @@
 PASS testForwardSlash("^\\\/$", "\/"); is true
 PASS testForwardSlash("^\\\\/$", "\\/"); is true
 PASS testForwardSlash("^\\\\\/$", "\\/"); is true
+PASS testForwardSlash("x/x/x", "x\/x\/x"); is true
+PASS testForwardSlash("x\/x/x", "x\/x\/x"); is true
+PASS testForwardSlash("x/x\/x", "x\/x\/x"); is true
+PASS testForwardSlash("x\/x\/x", "x\/x\/x"); is true
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/Source/_javascript_Core/ChangeLog (90246 => 90247)


--- trunk/Source/_javascript_Core/ChangeLog	2011-07-01 18:14:37 UTC (rev 90246)
+++ trunk/Source/_javascript_Core/ChangeLog	2011-07-01 18:19:17 UTC (rev 90247)
@@ -1,3 +1,16 @@
+2011-07-01  Gavin Barraclough  <[email protected]>
+
+        Reviewed by Sam Weinig.
+
+        https://bugs.webkit.org/show_bug.cgi?id=63819
+        Escaping of forwardslashes in strings incorrect if multiple exist.
+
+        The bug is in the parameters passed to a substring - should be
+        start & length, but we're passing start & end indices!
+
+        * runtime/RegExpObject.cpp:
+        (JSC::regExpObjectSource):
+
 2011-07-01  Adam Roben  <[email protected]>
 
         Roll out r90194

Modified: trunk/Source/_javascript_Core/runtime/RegExpObject.cpp (90246 => 90247)


--- trunk/Source/_javascript_Core/runtime/RegExpObject.cpp	2011-07-01 18:14:37 UTC (rev 90246)
+++ trunk/Source/_javascript_Core/runtime/RegExpObject.cpp	2011-07-01 18:19:17 UTC (rev 90247)
@@ -134,9 +134,9 @@
         // if odd, the forwards slash is already escaped, so we mustn't
         // double escape it.
         if ((forwardSlashPosition - slashesPosition) & 1)
-            result.append(pattern.substringSharingImpl(completed, forwardSlashPosition + 1));
+            result.append(pattern.substringSharingImpl(completed, forwardSlashPosition - completed + 1));
         else {
-            result.append(pattern.substringSharingImpl(completed, forwardSlashPosition));
+            result.append(pattern.substringSharingImpl(completed, forwardSlashPosition - completed));
             result.append("\\/");
         }
         completed = forwardSlashPosition + 1;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to