Closed Bug 92942 Opened 23 years ago Closed 23 years ago

String.prototype.replace not ECMAScript Ed. 3 compliant

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

VERIFIED INVALID

People

(Reporter: jim, Assigned: rogerl)

References

()

Details

ECMA 262 Ed 3: states:

"15.5.4.11 String.prototype.replace (regexp, replaceValue)
If regexp is not an object whose [[Class]] property is "RegExp", it is replaced 
with the result of the expression new
RegExp(regexp). "

JavaScript 1.5 does:

"aa$aa".replace("$","z")  == "aazaa"
Compliant ECMAScript engines do:
"aa$aa".replace("$","z")  == "aa$aaz"

Opera 5, and older JavaScript versions are Compliant in this respect, JScript 
is also non-compliant.

Tested with Build ID 2001073103  also with "Netscape 6".
Status: UNCONFIRMED → NEW
Ever confirmed: true
Jim, you are correct. I have added your example to the existing testcase

          mozilla/js/tests/ecma_3/String/regress-83293.js

This is a duplicate of bug 83293. You will be cc'ed on that bug so you
can follow its progress until it gets fixed. Thank you for this report!




*** This bug has been marked as a duplicate of 83293 ***
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → DUPLICATE
Summary: String.prototype.replace not ECMAScript Ed. 3 Compliant → String.prototype.replace not ECMAScript Ed. 3 compliant
Marking Verified -
Status: RESOLVED → VERIFIED
OS: Windows 98 → All
Hardware: Other → All
From bug 83293:


------- Additional Comments From Jim Ley 2001-08-05 13:52 -------

I hate to say this, for fear of killing the fixes, but the quotation from the 
ECMA-262 Ed. 3 is incorrect, that is one the one in the released final draft I 
believe, the actual standard - My copy dated "09-02-00 14,32" (assumed Swiss 
date so 2000-02-09) contains:

------------------------------------------------------------------------------

15.5.4.11 String.prototype.replace (searchValue, replaceValue) 

Let string denote the result of converting the this value to a string.
If searchValue is a regular expression (an object whose [[Class]]
property is "RegExp"), do the following: If searchValue.global is
false, then search string for the first match of the regular
expression searchValue. If searchValue.global is true, then search
string for all matches of the regular expression searchValue. Do the
search in the same manner as in String.prototype.match, including the
update of searchValue.lastIndex. Let m be the number of left capturing
parentheses in searchValue (NCapturingParens as specified in
15.10.2.1). 

If searchValue is not a regular expression, let searchString be
ToString(searchValue) and search string for the first occurrence of
searchString. Let m be 0.

------------------------------------------------------------------------------

This is different to the NN4.7 situation:

                                            NN4.7    ECMAScript
javascript:alert("a$a".replace('$','Z'))    'a$aZ'      'aZa'


Jim.
Jim is correct to point out this change in the ECMAScript spec between
the Edition 3 "Final Draft" (October 1999) and the "Final Edition" 
(December 1999). For a complete discussion, see bug 83293.

In the meantime, that makes this bug invalid, so I am reopening it 
to give it that status -
Status: VERIFIED → REOPENED
Resolution: DUPLICATE → ---
Resolving as Invalid - 
Status: REOPENED → RESOLVED
Closed: 23 years ago23 years ago
Resolution: --- → INVALID
Marking Verified - 
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.