Bug 21431

Summary: String.replace does not support $& replacement metacharacter when search term is not a RegExp
Product: WebKit Reporter: Mark Rowe (bdash) <mrowe>
Component: JavaScriptCoreAssignee: Darin Adler <darin>
Status: RESOLVED FIXED    
Severity: Normal CC: dmandelin
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Mac   
OS: OS X 10.5   
URL: javascript:alert("asdf".replace("as", "$&$&$&"))
Attachments:
Description Flags
patch oliver: review+

Mark Rowe (bdash)
Reported 2008-10-07 10:04:12 PDT
"asdf".replace("as", "$&$&$&") gives "$&$&$&df" rather than the expected "asasasdf". "asdf".replace(/as/, "$&$&$&") correctly gives "asasasdf".
Attachments
patch (6.15 KB, patch)
2008-12-30 23:26 PST, Darin Adler
oliver: review+
Mark Rowe (bdash)
Comment 1 2008-10-07 10:08:20 PDT
Darin Adler
Comment 2 2008-12-24 23:02:02 PST
stringProtoFuncReplace needs to call substituteBackreferences on replacementString
Darin Adler
Comment 3 2008-12-30 23:26:37 PST
Darin Adler
Comment 4 2009-01-01 21:57:40 PST
Note You need to log in before you can comment on or make changes to this bug.