From 7b7134405118e944f87772edc41c3ddec856cdff Mon Sep 17 00:00:00 2001 From: Anthony Van de Gejuchte Date: Tue, 10 Feb 2015 16:57:17 +0100 Subject: [PATCH] Parse regexes properly --- bin/uglifyjs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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 { -- 2.34.1