mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 854124 - Update RegExpStatics on empty match in str_replace_regexp_remove(). r=dvander
This commit is contained in:
parent
d46c720a8d
commit
001adc7fbf
8
js/src/jit-test/tests/basic/bug854124.js
Normal file
8
js/src/jit-test/tests/basic/bug854124.js
Normal file
@ -0,0 +1,8 @@
|
||||
// Don't assert.
|
||||
"p".match(/(p)/);
|
||||
assertEq(RegExp.$1, "p");
|
||||
assertEq(RegExp.$2, "");
|
||||
|
||||
"x\ny\n".replace(/(^\n*)/, "");
|
||||
assertEq(RegExp.$1, "");
|
||||
assertEq(RegExp.$2, "");
|
@ -2465,16 +2465,18 @@ str_replace_regexp_remove(JSContext *cx, CallArgs args, HandleString str, RegExp
|
||||
lazyIndex = lastIndex;
|
||||
lastIndex = startIndex;
|
||||
|
||||
if (match.isEmpty())
|
||||
startIndex++;
|
||||
|
||||
/* Non-global removal executes at most once. */
|
||||
if (!re.global())
|
||||
break;
|
||||
|
||||
if (match.isEmpty())
|
||||
startIndex++;
|
||||
}
|
||||
|
||||
/* If unmatched, return the input string. */
|
||||
if (!lastIndex) {
|
||||
if (startIndex > 0)
|
||||
cx->regExpStatics()->updateLazily(cx, stableStr, &re, lazyIndex);
|
||||
args.rval().setString(str);
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user