Ignore:
Timestamp:
Jun 27, 2011, 10:55:45 PM (14 years ago)
Author:
[email protected]
Message:

Source/JavaScriptCore: Build fix attempt after r89885.

Patch by Ryosuke Niwa <[email protected]> on 2011-06-27

LayoutTests: https://bugs.webkit.org/show_bug.cgi?id=50554
RegExp.prototype.toString does not escape slashes

Reviewed by Darin Adler & Oliver Hunt.

The problem here is that we don't escape forwards slashes when converting
a RegExp to a string. This means that RegExp("/").toString() is "/",
which is not a valid RegExp literal. Also, we return an invalid literal
for RegExp.prototype.toString() ("
", which is an empty single-line comment).

From ES5:
"NOTE: The returned String has the form of a RegularExpressionLiteral that
evaluates to another RegExp object with the same behaviour as this object."

Added test cases.

  • fast/regex/script-tests/toString.js: Added.

(testFwdSlash):

  • fast/regex/toString-expected.txt: Added.
  • fast/regex/toString.html: Added.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r89887 r89895  
    5252        (JSC::SafeRecompiler::operator()):
    5353        (JSC::JSGlobalData::releaseExecutableMemory):
     54
     552011-06-27  Gavin Barraclough  <[email protected]>
     56
     57        Reviewed by Darin Adler & Oliver Hunt.
     58
     59        https://bugs.webkit.org/show_bug.cgi?id=50554
     60        RegExp.prototype.toString does not escape slashes
     61
     62        The problem here is that we don't escape forwards slashes when converting
     63        a RegExp to a string. This means that RegExp("/").toString() is "///",
     64        which is not a valid RegExp literal. Also, we return an invalid literal
     65        for RegExp.prototype.toString() ("//", which is an empty single-line comment).
     66
     67        From ES5:
     68        "NOTE: The returned String has the form of a RegularExpressionLiteral that
     69        evaluates to another RegExp object with the same behaviour as this object."
     70
     71        * runtime/RegExpObject.cpp:
     72        (JSC::regExpObjectSource):
     73            - Escape forward slashes when getting the source of a RegExp.
     74        * runtime/RegExpPrototype.cpp:
     75        (JSC::regExpProtoFuncToString):
     76            - Remove unnecessary and erroneous hack to return "//" as the string
     77            representation of RegExp.prototype. This is not a valid RegExp literal
     78            (it is an empty single-line comment).
    5479
    55802011-06-27  Gavin Barraclough  <[email protected]>
Note: See TracChangeset for help on using the changeset viewer.