Invalid String.prototype.replace with string search value: "a>".replace(/>/, "$+") returns "a"
Categories
(Core :: JavaScript Engine, defect, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox93 | --- | fixed |
People
(Reporter: 1059252359, Assigned: evilpies)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0
Steps to reproduce:
var NISLFuzzingFunc = function(e,nislMutationParameter0){
return e.replace(/>/,nislMutationParameter0);
};
var NISLParameter0 = 'a>';
var nislMutationArgument0 = '$+';
var NISLCallingResult = NISLFuzzingFunc(NISLParameter0,nislMutationArgument0);
print(NISLCallingResult);
Actual results:
The output is "a".
Expected results:
The above program should output "a$+".
Comment 1•5 years ago
|
||
$+
is a SpiderMonkey extension.
![]() |
||
Comment 2•5 years ago
|
||
I think the '$' character needs to be escaped with $.
"a>".replace(/>/, "$$+")
Comment 3•5 years ago
|
||
Should we just remove this non-standard extension? It's not even in the MDN docs.
It doesn't seem worth the (probably small, but still) web compat risk.
Comment 4•5 years ago
|
||
We could try to remove this by starting to warn about it. I don't expect any web-sites issues, because we're the only browser supporting this extension, but addons could be affected.
Comment 5•5 years ago
|
||
I vote we just remove it. I'd be surprised if any addons are using this.
RegExp.lastParen
and RegExp['$+']
are also nonstandard but documented and widely implemented. They work in Chrome. They can't be removed.
Updated•5 years ago
|
Comment 6•5 years ago
|
||
(In reply to Jason Orendorff [:jorendorff] from comment #5)
RegExp.lastParen
andRegExp['$+']
are also nonstandard but documented and widely implemented. They work in Chrome. They can't be removed.
https://github.com/tc39/proposal-regexp-legacy-features, but that proposal isn't super active.
Updated•4 years ago
|
I agree with Jason from a year ago, just removing this is hopefully fine. Most programs probably won't have catastrophic failures with some unreplaced string.
![]() |
||
Comment 10•3 years ago
|
||
bugherder |
Description
•