Strip backslash from escaped / when lexing regular expressions.

This commit is contained in:
Tor Andersson
2014-09-24 14:05:59 +02:00
parent bc845cbd64
commit 2e196dd0fc

14
jslex.c
View File

@@ -464,11 +464,15 @@ static int lexregexp(js_State *J)
if (PEEK == 0 || PEEK == '\n') {
jsY_error(J, "regular expression not terminated");
} else if (ACCEPT('\\')) {
textpush(J, '\\');
if (PEEK == 0 || PEEK == '\n')
jsY_error(J, "regular expression not terminated");
textpush(J, PEEK);
NEXT();
if (ACCEPT('/')) {
textpush(J, '/');
} else {
textpush(J, '\\');
if (PEEK == 0 || PEEK == '\n')
jsY_error(J, "regular expression not terminated");
textpush(J, PEEK);
NEXT();
}
} else {
textpush(J, PEEK);
NEXT();