[Pkg-javascript-commits] [uglifyjs] 155/190: Do not allow newlines in regex

Antonio Terceiro terceiro at moszumanska.debian.org
Sun Aug 7 23:17:22 UTC 2016


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

terceiro pushed a commit to annotated tag upstream/2.7.0
in repository uglifyjs.

commit 00ad57e393be6593c9a405c8b1277582361bd321
Author: Anthony Van de Gejuchte <anthonyvdgent at gmail.com>
Date:   Sun Jun 5 02:44:59 2016 +0200

    Do not allow newlines in regex
---
 lib/parse.js               |  2 ++
 test/mocha/line-endings.js | 22 ++++++++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/lib/parse.js b/lib/parse.js
index be103b6..467fc60 100644
--- a/lib/parse.js
+++ b/lib/parse.js
@@ -490,6 +490,8 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
             break;
         } else if (ch == "\\") {
             prev_backslash = true;
+        } else if ("\r\n\u2028\u2029".indexOf(ch) >= 0) {
+            parse_error("Unexpected line terminator");
         } else {
             regexp += ch;
         }
diff --git a/test/mocha/line-endings.js b/test/mocha/line-endings.js
index 8fd56a1..3457dd7 100644
--- a/test/mocha/line-endings.js
+++ b/test/mocha/line-endings.js
@@ -30,5 +30,27 @@ describe("line-endings", function() {
         var result = Uglify.minify(js, options);
         assert.strictEqual(result.code, expected_code);
     });
+
+    it("Should not allow line terminators in regexp", function() {
+        var inputs = [
+            "/\n/",
+            "/\r/",
+            "/\u2028/",
+            "/\u2029/",
+            "/someRandomTextLike[]()*AndThen\n/"
+        ]
+        var test = function(input) {
+            return function() {
+                Uglify.parse(input);
+            }
+        }
+        var fail = function(e) {
+            return e instanceof Uglify.JS_Parse_Error &&
+                e.message === "Unexpected line terminator";
+        }
+        for (var i = 0; i < inputs.length; i++) {
+            assert.throws(test(inputs[i]), fail);
+        }
+    });
 });
 

-- 
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