Closed
Bug 591318
Opened 14 years ago
Closed 14 years ago
Invalid String.prototype.replace with string search value: "a".replace("$", "\\$") returns "a\$"
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
WORKSFORME
People
(Reporter: mayhemer, Unassigned)
Details
Expected result is "a".
Also:
"a".replace(".", "\\$")) returns "\$",
"a".replace("^", "\\$")) returns "\$a"
The first argument is clearly taken as regexp.
This cannot be reproduced with the second argument different from "\\$".
This bug appears in Firefox 4 beta 4, was not present in Firefox 4 beta 3. I don't have narrower regression range at the moment.
Workaround: "a".replace(/\$/g, "\\$") returns "a" as expected.
Comment 1•14 years ago
|
||
The first argument to the String.prototype.replace is *not* automatically converted to a regular expression, per ECMAScript 5th edition section 15.5.4.11 paragraph two:
"If searchValue is not a regular expression, let searchString be toString(searchValue) and search string for the first occurrence of searchString."
Also see recent bug 587366. Thanks for filing, though!
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → INVALID
Updated•14 years ago
|
Summary: "a".replace("$", "\\$") returns "a\$" → Invalid String.prototype.replace with string search value: "a".replace("$", "\\$") returns "a\$"
Comment 2•14 years ago
|
||
No this was fixed by Bug 587366 in range of http://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=2f01056be931&tochange=0aefd9d484f1
Resolution: INVALID → WORKSFORME
Comment 3•14 years ago
|
||
Er yeah, whoops... that was the bug we fixed. Thanks for the correction Alice0775 White.
You need to log in
before you can comment on or make changes to this bug.
Description
•