jscript: Correctly handle empty matches in String.replace.
This commit is contained in:
parent
e21588aef7
commit
c1cb8f29b0
|
@ -868,6 +868,9 @@ static HRESULT String_replace(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI
|
|||
}
|
||||
if(FAILED(hres))
|
||||
break;
|
||||
|
||||
if(!match.len)
|
||||
cp++;
|
||||
}else {
|
||||
match.str = strstrW(cp, match_str);
|
||||
if(!match.str)
|
||||
|
|
|
@ -583,4 +583,13 @@ ok(i === null, "' undefined '.search() = " + i);
|
|||
tmp = "=)".replace(/=/, "?");
|
||||
ok(tmp === "?)", "'=)'.replace(/=/, '?') = " + tmp);
|
||||
|
||||
tmp = " ".replace(/^\s*|\s*$/g, "y");
|
||||
ok(tmp === "yy", '" ".replace(/^\s*|\s*$/g, "y") = ' + tmp);
|
||||
|
||||
tmp = "xxx".replace(/^\s*|\s*$/g, "");
|
||||
ok(tmp === "xxx", '"xxx".replace(/^\s*|\s*$/g, "y") = ' + tmp);
|
||||
|
||||
tmp = "xxx".replace(/^\s*|\s*$/g, "y");
|
||||
ok(tmp === "yxxxy", '"xxx".replace(/^\s*|\s*$/g, "y") = ' + tmp);
|
||||
|
||||
reportSuccess();
|
||||
|
|
Loading…
Reference in New Issue