Ignore:
Timestamp:
Jul 1, 2011, 11:19:17 AM (14 years ago)
Author:
[email protected]
Message:

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

Reviewed by Sam Weinig.

Source/JavaScriptCore:

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:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/RegExpObject.cpp

    r89895 r90247  
    135135        // double escape it.
    136136        if ((forwardSlashPosition - slashesPosition) & 1)
    137             result.append(pattern.substringSharingImpl(completed, forwardSlashPosition + 1));
     137            result.append(pattern.substringSharingImpl(completed, forwardSlashPosition - completed + 1));
    138138        else {
    139             result.append(pattern.substringSharingImpl(completed, forwardSlashPosition));
     139            result.append(pattern.substringSharingImpl(completed, forwardSlashPosition - completed));
    140140            result.append("\\/");
    141141        }
Note: See TracChangeset for help on using the changeset viewer.