Bug 170151 - String.prototype.replace incorrectly applies "special replacement parameters" when passed a function
Summary: String.prototype.replace incorrectly applies "special replacement parameters"...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: Safari 10
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-03-27 17:45 PDT by twalpole
Modified: 2017-04-14 08:32 PDT (History)
14 users (show)

See Also:


Attachments
Patch (9.07 KB, patch)
2017-03-30 09:36 PDT, GSkachkov
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews107 for mac-elcapitan-wk2 (1.03 MB, application/zip)
2017-03-30 14:29 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews112 for mac-elcapitan (2.06 MB, application/zip)
2017-03-30 14:40 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews102 for mac-elcapitan (917.94 KB, application/zip)
2017-03-30 14:43 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews121 for ios-simulator-wk2 (14.21 MB, application/zip)
2017-03-30 15:08 PDT, Build Bot
no flags Details
Patch (9.14 KB, patch)
2017-03-31 00:59 PDT, GSkachkov
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description twalpole 2017-03-27 17:45:24 PDT
When String.prototype.replace is passed a function as a second parameter it is incorrectly applying "special replacement patterns" to the returned results

var a="ABC";
a.replace("B", function(){ return "$$" });  // Should be "A$$C" - in Safari 10.1 and 10.2 it is "A$C"
Comment 1 Radar WebKit Bug Importer 2017-03-28 23:10:31 PDT
<rdar://problem/31315899>
Comment 2 GSkachkov 2017-03-29 12:13:22 PDT
I'll take look to this issue.
Comment 3 GSkachkov 2017-03-30 05:51:07 PDT
I'll upload patch soon, just need to make more proper tests
Comment 4 GSkachkov 2017-03-30 09:36:47 PDT
Created attachment 305864 [details]
Patch

Fix
Comment 5 Saam Barati 2017-03-30 10:06:42 PDT
Comment on attachment 305864 [details]
Patch

r=me
Comment 6 Build Bot 2017-03-30 14:29:44 PDT
Comment on attachment 305864 [details]
Patch

Attachment 305864 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/3442729

New failing tests:
js/string_replace_function.html
js/string_replace_regexp.html
Comment 7 Build Bot 2017-03-30 14:29:45 PDT
Created attachment 305903 [details]
Archive of layout-test-results from ews107 for mac-elcapitan-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews107  Port: mac-elcapitan-wk2  Platform: Mac OS X 10.11.6
Comment 8 Build Bot 2017-03-30 14:40:04 PDT
Comment on attachment 305864 [details]
Patch

Attachment 305864 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/3442751

New failing tests:
js/string_replace_function.html
js/string_replace_regexp.html
Comment 9 Build Bot 2017-03-30 14:40:05 PDT
Created attachment 305906 [details]
Archive of layout-test-results from ews112 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews112  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 10 Build Bot 2017-03-30 14:43:28 PDT
Comment on attachment 305864 [details]
Patch

Attachment 305864 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/3442798

New failing tests:
js/string_replace_function.html
js/string_replace_regexp.html
Comment 11 Build Bot 2017-03-30 14:43:29 PDT
Created attachment 305907 [details]
Archive of layout-test-results from ews102 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews102  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 12 Build Bot 2017-03-30 15:08:56 PDT
Comment on attachment 305864 [details]
Patch

Attachment 305864 [details] did not pass ios-sim-ews (ios-simulator-wk2):
Output: http://webkit-queues.webkit.org/results/3442825

New failing tests:
js/string_replace_function.html
js/string_replace_regexp.html
Comment 13 Build Bot 2017-03-30 15:08:58 PDT
Created attachment 305911 [details]
Archive of layout-test-results from ews121 for ios-simulator-wk2

The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews121  Port: ios-simulator-wk2  Platform: Mac OS X 10.11.6
Comment 14 GSkachkov 2017-03-31 00:59:05 PDT
Created attachment 305952 [details]
Patch

Rebased version to check builds
Comment 15 GSkachkov 2017-03-31 05:09:31 PDT
Patch landed https://trac.webkit.org/changeset/214662
Comment 16 Saam Barati 2017-04-13 19:08:08 PDT
(In reply to GSkachkov from comment #15)
> Patch landed https://trac.webkit.org/changeset/214662

Please close out the bugs when landing fixes. Also, no need for r? on any patches once things have landed.
Comment 17 GSkachkov 2017-04-13 20:17:10 PDT
(In reply to Saam Barati from comment #16)
> (In reply to GSkachkov from comment #15)
> > Patch landed https://trac.webkit.org/changeset/214662
> 
> Please close out the bugs when landing fixes. Also, no need for r? on any
> patches once things have landed.

Sorry, but I don't have permissions to do this, I only  can close bugs that I created. Yeah for this bugs I've have been waiting until webkit nightly starts works to ask authors to check fix and close the issue.
Comment 18 Saam Barati 2017-04-14 08:32:01 PDT
(In reply to GSkachkov from comment #17)
> (In reply to Saam Barati from comment #16)
> > (In reply to GSkachkov from comment #15)
> > > Patch landed https://trac.webkit.org/changeset/214662
> > 
> > Please close out the bugs when landing fixes. Also, no need for r? on any
> > patches once things have landed.
> 
> Sorry, but I don't have permissions to do this, I only  can close bugs that
> I created. Yeah for this bugs I've have been waiting until webkit nightly
> starts works to ask authors to check fix and close the issue.

Ah, ok. Let me try to get you edit bugs privileges so you can close bugs you didn't create.