From 668c4a382f1919d13772d2d66fbea75e9c6b3b3b Mon Sep 17 00:00:00 2001 From: Mike Pennisi Date: Wed, 6 Feb 2019 21:42:59 -0500 Subject: [PATCH] [[FIX]] Correct parsing of RegExp character sets Do not interpret RegExp syntax characters using their specialized semantics when they appear within a character set. --- src/lex.js | 5 +++++ tests/unit/parser.js | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/src/lex.js b/src/lex.js index 1ea296ae9e..1b1540c7e9 100644 --- a/src/lex.js +++ b/src/lex.js @@ -1582,6 +1582,11 @@ Lexer.prototype = { continue; } + if (isCharSet) { + index += 1; + continue; + } + if (char === "{" && !hasInvalidQuantifier) { hasInvalidQuantifier = !checkQuantifier(); } diff --git a/tests/unit/parser.js b/tests/unit/parser.js index c5e049b198..10efb3a2cd 100644 --- a/tests/unit/parser.js +++ b/tests/unit/parser.js @@ -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(); };