Skip to content

Commit

Permalink
[[FIX]] Correct parsing of RegExp character sets
Browse files Browse the repository at this point in the history
Do not interpret RegExp syntax characters using their specialized
semantics when they appear within a character set.
  • Loading branch information
jugglinmike authored and rwaldron committed Feb 20, 2019
1 parent 0e85de5 commit 668c4a3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lex.js
Expand Up @@ -1582,6 +1582,11 @@ Lexer.prototype = {
continue;
}

if (isCharSet) {
index += 1;
continue;
}

if (char === "{" && !hasInvalidQuantifier) {
hasInvalidQuantifier = !checkQuantifier();
}
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/parser.js
Expand Up @@ -866,6 +866,12 @@ exports.regexp.regressions = function (test) {
TestRun(test).test("var exp = /\\[\\]/;", {esnext: true});
TestRun(test).test("var exp = /\\[\\]/;", {moz: true});

// GH-3356
TestRun(test).test("void /[/]/;");
TestRun(test).test("void /[{]/u;", {esversion: 6});
TestRun(test).test("void /[(?=)*]/u;", {esversion: 6});
TestRun(test).test("void /[(?!)+]/u;", {esversion: 6});

test.done();
};

Expand Down

0 comments on commit 668c4a3

Please sign in to comment.