archives

« Bugzilla Issues Index

#2849 — 21.2.5.7 RegExp.prototype.replace: Missing string index checks in step 18


21.2.5.7 RegExp.prototype.replace ( string, replaceValue ), step 18:

nextSrcPosition may exceed the final code unit of S, add a conditional step to ensure only valid string ranges are used.

> 18: If nextSrcPosition is less than the final code unit of S, then add code units from nextSrcPosition up through ... to accumulatedResult.
> 19: Return accumulatedResult.


Test case:
---
(new class extends RegExp {
exec(){
return {index: 0, 0: "abc"};
}
}).replace("a", "b");
---


fixed in rev25 editor's draft.


fixed in rev25 editor's draft