Commit c1cb8f29 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Correctly handle empty matches in String.replace.

parent e21588ae
...@@ -868,6 +868,9 @@ static HRESULT String_replace(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI ...@@ -868,6 +868,9 @@ static HRESULT String_replace(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI
} }
if(FAILED(hres)) if(FAILED(hres))
break; break;
if(!match.len)
cp++;
}else { }else {
match.str = strstrW(cp, match_str); match.str = strstrW(cp, match_str);
if(!match.str) if(!match.str)
......
...@@ -583,4 +583,13 @@ ok(i === null, "' undefined '.search() = " + i); ...@@ -583,4 +583,13 @@ ok(i === null, "' undefined '.search() = " + i);
tmp = "=)".replace(/=/, "?"); tmp = "=)".replace(/=/, "?");
ok(tmp === "?)", "'=)'.replace(/=/, '?') = " + tmp); 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(); reportSuccess();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment