From: Anthony Van de Gejuchte Date: Tue, 10 Feb 2015 15:57:17 +0000 (+0100) Subject: Parse regexes properly X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=7b7134405118e944f87772edc41c3ddec856cdff;p=UglifyJS.git Parse regexes properly --- diff --git a/bin/uglifyjs b/bin/uglifyjs index c9f4c12d..31133c93 100755 --- a/bin/uglifyjs +++ b/bin/uglifyjs @@ -178,8 +178,13 @@ if (BEAUTIFY) UglifyJS.merge(OUTPUT_OPTIONS, BEAUTIFY); if (ARGS.comments) { - if (/^\//.test(ARGS.comments)) { - OUTPUT_OPTIONS.comments = new Function("return(" + ARGS.comments + ")")(); + if (/^\/.*\/[a-zA-Z]*$/.test(ARGS.comments)) { + var regex_pos = ARGS.comments.lastIndexOf("/"); + try { + OUTPUT_OPTIONS.comments = new RegExp(ARGS.comments.substr(1, regex_pos - 1), ARGS.comments.substr(regex_pos + 1)); + } catch (e) { + sys.error("ERROR: Invalid --comments: " + e.message); + } } else if (ARGS.comments == "all") { OUTPUT_OPTIONS.comments = true; } else {