Changeset 65840 in webkit


Ignore:
Timestamp:
Aug 23, 2010 4:12:46 PM (14 years ago)
Author:
commit-queue@webkit.org
Message:

2010-08-23 Michael Saboff <msaboff@apple.com>

Reviewed by Oliver Hunt.

Fixed case where a single character search string in a string.replace()
did not properly handle back reference replacement. The fix is to
check for a '$' as part of the check to see if we can execute the
single character replace optimization.
https://bugs.webkit.org/show_bug.cgi?id=44067

  • runtime/StringPrototype.cpp: (JSC::stringProtoFuncReplace):
Location:
trunk/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r65834 r65840  
     12010-08-23  Michael Saboff  <msaboff@apple.com>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        Fixed case where a single character search string in a string.replace()
     6        did not properly handle back reference replacement.  The fix is to
     7        check for a '$' as part of the check to see if we can execute the
     8        single character replace optimization.
     9        https://bugs.webkit.org/show_bug.cgi?id=44067
     10
     11        * runtime/StringPrototype.cpp:
     12        (JSC::stringProtoFuncReplace):
     13
    1142010-08-23  Oliver Hunt  <oliver@apple.com>
    215
  • trunk/JavaScriptCore/runtime/StringPrototype.cpp

    r65593 r65840  
    426426
    427427    UString patternString = pattern.toString(exec);
    428     if (patternString.length() == 1 && callType == CallTypeNone)
     428    // Special case for single character patterns without back reference replacement
     429    if (patternString.length() == 1 && callType == CallTypeNone && replacementString.find('$', 0) == notFound)
    429430        return JSValue::encode(sourceVal->replaceCharacter(exec, patternString[0], replacementString));
    430    
     431
    431432    const UString& source = sourceVal->value(exec);
    432433    size_t matchPos = source.find(patternString);
Note: See TracChangeset for help on using the changeset viewer.