aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Van de Gejuchte <anthonyvdgent@yahoo.com>2015-02-10 16:57:17 +0100
committerRichard van Velzen <rvanvelzen1@gmail.com>2015-02-11 18:29:15 +0100
commit7b7134405118e944f87772edc41c3ddec856cdff (patch)
tree559f7923740f6909d4ff6a82636b9c737541939b
parent605362f89da444e46bae35e7f9384b5cba2eeb80 (diff)
downloadtracifyjs-7b7134405118e944f87772edc41c3ddec856cdff.tar.gz
tracifyjs-7b7134405118e944f87772edc41c3ddec856cdff.zip
Parse regexes properly
-rwxr-xr-xbin/uglifyjs9
1 files 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 {