summaryrefslogtreecommitdiffstats
path: root/JavaScriptCore/runtime/StringPrototype.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'JavaScriptCore/runtime/StringPrototype.cpp')
-rw-r--r--JavaScriptCore/runtime/StringPrototype.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/JavaScriptCore/runtime/StringPrototype.cpp b/JavaScriptCore/runtime/StringPrototype.cpp
index cfbb3be..91e9b06 100644
--- a/JavaScriptCore/runtime/StringPrototype.cpp
+++ b/JavaScriptCore/runtime/StringPrototype.cpp
@@ -425,9 +425,10 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncReplace(ExecState* exec)
// Not a regular expression, so treat the pattern as a string.
UString patternString = pattern.toString(exec);
- if (patternString.length() == 1 && callType == CallTypeNone)
+ // Special case for single character patterns without back reference replacement
+ if (patternString.length() == 1 && callType == CallTypeNone && replacementString.find('$', 0) == notFound)
return JSValue::encode(sourceVal->replaceCharacter(exec, patternString[0], replacementString));
-
+
const UString& source = sourceVal->value(exec);
size_t matchPos = source.find(patternString);