[Pkg-javascript-commits] [uglifyjs] 47/77: Parse regexes properly

Jonas Smedegaard dr at jones.dk
Tue May 19 00:02:31 UTC 2015


This is an automated email from the git hooks/post-receive script.

js pushed a commit to tag v2.4.18
in repository uglifyjs.

commit 7b7134405118e944f87772edc41c3ddec856cdff
Author: Anthony Van de Gejuchte <anthonyvdgent at yahoo.com>
Date:   Tue Feb 10 16:57:17 2015 +0100

    Parse regexes properly
---
 bin/uglifyjs | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/bin/uglifyjs b/bin/uglifyjs
index c9f4c12..31133c9 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 {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/uglifyjs.git



More information about the Pkg-javascript-commits mailing list