jscript: Fixed backslash handling in regular expressions.
This commit is contained in:
parent
383de2d79a
commit
31b3071552
|
@ -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) == '\\'))
|
||||
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");
|
||||
|
|
Loading…
Reference in New Issue