Changeset 23675 in webkit
- Timestamp:
- Jun 20, 2007 5:00:12 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r23540 r23675 1 2007-06-20 Mark Rowe <mrowe@apple.com> 2 3 Reviewed by Mitz. 4 5 Fix http://bugs.webkit.org/show_bug.cgi?id=14244 6 Bug 14244: Data corruption when using a replace() callback function with data containing "$" 7 8 * kjs/string_object.cpp: 9 (KJS::replace): When 'replacement' is a function, do not replace $n placeholders in its return value. 10 This matches the behaviour described in ECMA 262 3rd Ed section 15.5.4.1, and as implemented in Firefox. 11 1 12 2007-06-14 Anders Carlsson <andersca@apple.com> 2 13 -
trunk/JavaScriptCore/kjs/string_object.cpp
r21867 r23675 345 345 pushSourceRange(sourceRanges, sourceRangeCount, sourceRangeCapacity, UString::Range(lastIndex, matchIndex - lastIndex)); 346 346 347 UString substitutedReplacement; 347 348 if (replacementFunction) { 348 349 int completeMatchStart = ovector[0]; … … 350 351 351 352 args.append(jsString(matchString)); 352 353 353 354 for (unsigned i = 0; i < reg->subPatterns(); i++) { 354 355 int matchStart = ovector[(i + 1) * 2]; 355 356 int matchLen = ovector[(i + 1) * 2 + 1] - matchStart; 356 357 357 358 args.append(jsString(source.substr(matchStart, matchLen))); 358 359 } … … 361 362 args.append(jsString(source)); 362 363 363 replacementString= replacementFunction->call(exec, exec->dynamicInterpreter()->globalObject(),364 args)->toString(exec);365 } 366 367 UString substitutedReplacement = substituteBackreferences(replacementString, source, ovector, reg); 364 substitutedReplacement = replacementFunction->call(exec, exec->dynamicInterpreter()->globalObject(), 365 args)->toString(exec); 366 } else 367 substitutedReplacement = substituteBackreferences(replacementString, source, ovector, reg); 368 368 369 pushReplacement(replacements, replacementCount, replacementCapacity, substitutedReplacement); 369 370 -
trunk/LayoutTests/ChangeLog
r23661 r23675 1 2007-06-20 Mark Rowe <mrowe@apple.com> 2 3 Reviewed by Mitz. 4 5 Test for http://bugs.webkit.org/show_bug.cgi?id=14244 6 Bug 14244: Data corruption when using a replace() callback function with data containing "$" 7 8 * fast/js/resources/string-replace-2.js: Update to test with 'replaceValue' being a function returning strings with "$n" placeholders. 9 * fast/js/string-replace-2-expected.txt: 10 1 11 2007-06-20 Mitz Pettel <mitz@webkit.org> 2 12 -
trunk/LayoutTests/fast/js/resources/string-replace-2.js
r11995 r23675 16 16 shouldBe("testString.replace(/([aeiou])([a-z])/g, function Capitalize(orig,re1,re2) { return re1.toUpperCase()+re2; })", 17 17 "\"It's the End Of the wOrld As we knOw It, And I fEel fIne.\""); 18 shouldBe("testString.replace(/(.*)/g, function replaceWithDollars(matchGroup) { return '$1'; })", "\"$1$1\""); 19 shouldBe("testString.replace(/(.)(.*)/g, function replaceWithMultipleDollars(matchGroup) { return '$1$2'; })", "\"$1$2\""); 20 shouldBe("testString.replace(/(.)(.*)/, function checkReplacementArguments() { return arguments.length; })", "\"5\""); 18 21 19 22 var successfullyParsed = true; -
trunk/LayoutTests/fast/js/string-replace-2-expected.txt
r12001 r23675 10 10 PASS testString.replace(/([aeiou])([a-z])/g, function Capitalize(){ return RegExp.$1.toUpperCase()+RegExp.$2; }) is "It's the End Of the wOrld As we knOw It, And I fEel fIne." 11 11 PASS testString.replace(/([aeiou])([a-z])/g, function Capitalize(orig,re1,re2) { return re1.toUpperCase()+re2; }) is "It's the End Of the wOrld As we knOw It, And I fEel fIne." 12 PASS testString.replace(/(.*)/g, function replaceWithDollars(matchGroup) { return '$1'; }) is "$1$1" 13 PASS testString.replace(/(.)(.*)/g, function replaceWithMultipleDollars(matchGroup) { return '$1$2'; }) is "$1$2" 14 PASS testString.replace(/(.)(.*)/, function checkReplacementArguments() { return arguments.length; }) is "5" 12 15 PASS successfullyParsed is true 13 16
Note: See TracChangeset
for help on using the changeset viewer.