aboutsummaryrefslogtreecommitdiff
path: root/test/mocha/line-endings.js
diff options
context:
space:
mode:
authorAnthony Van de Gejuchte <anthonyvdgent@gmail.com>2016-06-05 02:44:59 +0200
committerRichard van Velzen <rvanvelzen@experty.com>2016-06-05 17:02:19 +0200
commit00ad57e393be6593c9a405c8b1277582361bd321 (patch)
treebfec3448c29004ba77742e1515f8578e73e8270d /test/mocha/line-endings.js
parent09d5707a8a368d6498f39a8b9fd07226a1159d76 (diff)
downloadtracifyjs-00ad57e393be6593c9a405c8b1277582361bd321.tar.gz
tracifyjs-00ad57e393be6593c9a405c8b1277582361bd321.zip
Do not allow newlines in regex
Diffstat (limited to 'test/mocha/line-endings.js')
-rw-r--r--test/mocha/line-endings.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/mocha/line-endings.js b/test/mocha/line-endings.js
index 8fd56a19..3457dd70 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);
+ }
+ });
});