From 74c714bce9ed2e6b5bdd86397cf1909153ef2c61 Mon Sep 17 00:00:00 2001 From: Chris Cowan Date: Thu, 14 May 2015 12:03:54 -0700 Subject: [PATCH] Give a good error message if an invalid regular expression is found. --- lib/parse.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/parse.js b/lib/parse.js index 3cc2da51..b6645f49 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -480,7 +480,13 @@ function tokenizer($TEXT, filename, html5_comments) { regexp += ch; } var mods = read_name(); - return token("regexp", new RegExp(regexp, mods)); + var r; + try { + r = new RegExp(regexp, mods); + } catch(e) { + parse_error("Invalid regular expression"); + } + return token("regexp", r); }); function read_operator(prefix) {