Title: [97680] trunk
Revision
97680
Author
[email protected]
Date
2011-10-17 17:33:15 -0700 (Mon, 17 Oct 2011)

Log Message

Exception ordering in String.prototype.replace
https://bugs.webkit.org/show_bug.cgi?id=70290

Source/_javascript_Core: 

If pattern is not a regexp, it should be converted toString before the replacement value has it's toString conversion called.

Reviewed by Oliver Hunt.

* runtime/StringPrototype.cpp:
(JSC::stringProtoFuncReplace):

LayoutTests: 

Reviewed by Oliver Hunt.

* sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.11_String.prototype.replace/S15.5.4.11_A1_T11-expected.txt:
* sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.11_String.prototype.replace/S15.5.4.11_A1_T12-expected.txt:
    - Check in passing results.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (97679 => 97680)


--- trunk/LayoutTests/ChangeLog	2011-10-18 00:26:08 UTC (rev 97679)
+++ trunk/LayoutTests/ChangeLog	2011-10-18 00:33:15 UTC (rev 97680)
@@ -1,3 +1,14 @@
+2011-10-17  Gavin Barraclough  <[email protected]>
+
+        Exception ordering in String.prototype.replace
+        https://bugs.webkit.org/show_bug.cgi?id=70290
+
+        Reviewed by Oliver Hunt.
+
+        * sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.11_String.prototype.replace/S15.5.4.11_A1_T11-expected.txt:
+        * sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.11_String.prototype.replace/S15.5.4.11_A1_T12-expected.txt:
+            - Check in passing results.
+
 2011-10-17  Alok Priyadarshi  <[email protected]>
 
         Add layout tests for WebPlugin compositor path

Modified: trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.11_String.prototype.replace/S15.5.4.11_A1_T11-expected.txt (97679 => 97680)


--- trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.11_String.prototype.replace/S15.5.4.11_A1_T11-expected.txt	2011-10-18 00:26:08 UTC (rev 97679)
+++ trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.11_String.prototype.replace/S15.5.4.11_A1_T11-expected.txt	2011-10-18 00:33:15 UTC (rev 97680)
@@ -1,6 +1,6 @@
 S15.5.4.11_A1_T11
 
-FAIL SputnikError: #1.1: Exception === "insearchValue". Actual: inreplaceValue
+PASS 
 
 TEST COMPLETE
 

Modified: trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.11_String.prototype.replace/S15.5.4.11_A1_T12-expected.txt (97679 => 97680)


--- trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.11_String.prototype.replace/S15.5.4.11_A1_T12-expected.txt	2011-10-18 00:26:08 UTC (rev 97679)
+++ trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.11_String.prototype.replace/S15.5.4.11_A1_T12-expected.txt	2011-10-18 00:33:15 UTC (rev 97680)
@@ -1,6 +1,6 @@
 S15.5.4.11_A1_T12
 
-FAIL SputnikError: #1.1: Exception === "insearchValue". Actual: inreplaceValue
+PASS 
 
 TEST COMPLETE
 

Modified: trunk/Source/_javascript_Core/ChangeLog (97679 => 97680)


--- trunk/Source/_javascript_Core/ChangeLog	2011-10-18 00:26:08 UTC (rev 97679)
+++ trunk/Source/_javascript_Core/ChangeLog	2011-10-18 00:33:15 UTC (rev 97680)
@@ -1,3 +1,15 @@
+2011-10-17  Gavin Barraclough  <[email protected]>
+
+        Exception ordering in String.prototype.replace
+        https://bugs.webkit.org/show_bug.cgi?id=70290
+
+        If pattern is not a regexp, it should be converted toString before the replacement value has it's toString conversion called.
+
+        Reviewed by Oliver Hunt.
+
+        * runtime/StringPrototype.cpp:
+        (JSC::stringProtoFuncReplace):
+
 2011-10-17  Filip Pizlo  <[email protected]>
 
         DFG bytecode parser should understand inline stacks

Modified: trunk/Source/_javascript_Core/runtime/StringPrototype.cpp (97679 => 97680)


--- trunk/Source/_javascript_Core/runtime/StringPrototype.cpp	2011-10-18 00:26:08 UTC (rev 97679)
+++ trunk/Source/_javascript_Core/runtime/StringPrototype.cpp	2011-10-18 00:33:15 UTC (rev 97680)
@@ -360,13 +360,13 @@
     JSValue replacement = exec->argument(1);
     JSGlobalData* globalData = &exec->globalData();
 
-    UString replacementString;
-    CallData callData;
-    CallType callType = getCallData(replacement, callData);
-    if (callType == CallTypeNone)
-        replacementString = replacement.toString(exec);
+    if (pattern.inherits(&RegExpObject::s_info)) {
+        UString replacementString;
+        CallData callData;
+        CallType callType = getCallData(replacement, callData);
+        if (callType == CallTypeNone)
+            replacementString = replacement.toString(exec);
 
-    if (pattern.inherits(&RegExpObject::s_info)) {
         const UString& source = sourceVal->value(exec);
         unsigned sourceLen = source.length();
         if (exec->hadException())
@@ -538,7 +538,19 @@
 
     // Not a regular _expression_, so treat the pattern as a string.
 
+    // 'patternString' (or 'searchValue', as it is referred to in the spec) is converted before the replacement.
     UString patternString = pattern.toString(exec);
+    if (exec->hadException())
+        return JSValue::encode(jsUndefined());
+
+    UString replacementString;
+    CallData callData;
+    CallType callType = getCallData(replacement, callData);
+    if (callType == CallTypeNone)
+        replacementString = replacement.toString(exec);
+    if (exec->hadException())
+        return JSValue::encode(jsUndefined());
+
     // 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));
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to