Commit 31b30715 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Fixed backslash handling in regular expressions.

parent 383de2d7
......@@ -709,8 +709,10 @@ literal_t *parse_regexp(parser_ctx_t *ctx)
TRACE("\n");
re = ctx->ptr;
while(ctx->ptr < ctx->end && (*ctx->ptr != '/' || *(ctx->ptr-1) == '\\'))
ctx->ptr++;
while(ctx->ptr < ctx->end && *ctx->ptr != '/') {
if(*ctx->ptr++ == '\\' && ctx->ptr < ctx->end)
ctx->ptr++;
}
if(ctx->ptr == ctx->end) {
WARN("unexpected end of file\n");
......
......@@ -47,10 +47,16 @@ ok(m["1"] === "ab", "m[1] is not \"ab\"");
m = "aaabcabc".match(/a+b/g);
ok(typeof(m) === "object", "typeof m is not object");
ok(m.length === 2, "m.length is not 1");
ok(m.length === 2, "m.length is not 2");
ok(m["0"] === "aaab", "m[0] is not \"ab\"");
ok(m["1"] === "ab", "m[1] is not \"ab\"");
m = "aaa\\\\cabc".match(/\\/g);
ok(typeof(m) === "object", "typeof m is not object");
ok(m.length === 2, "m.length is not 2");
ok(m["0"] === "\\", "m[0] is not \"\\\"");
ok(m["1"] === "\\", "m[1] is not \"\\\"");
m = "abcabc".match(new RegExp("ab"));
ok(typeof(m) === "object", "typeof m is not object");
ok(m.length === 1, "m.length is not 1");
......
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