[Pkg-javascript-commits] [uglifyjs] 164/190: Don't allow with statements in strict mode
Antonio Terceiro
terceiro at moszumanska.debian.org
Sun Aug 7 23:17:23 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 bb9c9707aa6b4c625ad985798aea879080411ce1
Author: Anthony Van de Gejuchte <anthonyvdgent at gmail.com>
Date: Sun Jun 12 18:58:20 2016 +0200
Don't allow with statements in strict mode
---
lib/parse.js | 3 +++
test/mocha/with.js | 16 ++++++++++++++++
2 files changed, 19 insertions(+)
diff --git a/lib/parse.js b/lib/parse.js
index 4530c2d..2c00796 100644
--- a/lib/parse.js
+++ b/lib/parse.js
@@ -928,6 +928,9 @@ function parse($TEXT, options) {
return tmp = const_(), semicolon(), tmp;
case "with":
+ if (S.input.has_directive("use strict")) {
+ croak("Strict mode may not include a with statement");
+ }
return new AST_With({
expression : parenthesised(),
body : statement()
diff --git a/test/mocha/with.js b/test/mocha/with.js
new file mode 100644
index 0000000..d284f1c
--- /dev/null
+++ b/test/mocha/with.js
@@ -0,0 +1,16 @@
+var assert = require("assert");
+var uglify = require("../../");
+
+describe("With", function() {
+ it ("Should throw syntaxError when using with statement in strict mode", function() {
+ var code = '"use strict";\nthrow NotEarlyError;\nwith ({}) { }';
+ var test = function() {
+ uglify.parse(code);
+ }
+ var error = function(e) {
+ return e instanceof uglify.JS_Parse_Error &&
+ e.message === "Strict mode may not include a with statement";
+ }
+ assert.throws(test, error);
+ });
+});
\ No newline at end of file
--
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