From: Chris Cowan Date: Thu, 14 May 2015 19:03:54 +0000 (-0700) Subject: Give a good error message if an invalid regular expression is found. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=d6814050dd42298abb02e3fee2856174e02f01fa;p=UglifyJS.git Give a good error message if an invalid regular expression is found. --- diff --git a/lib/parse.js b/lib/parse.js index e65c4faa..70ee2e80 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) {