diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2018-02-19 18:47:02 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-19 18:47:02 +0800 |
commit | 70474310f3ba7f2f4395117ad2d779ced016075b (patch) | |
tree | 76f81688be3173ca2123c209000fb80c4f9c46ad | |
parent | b5f0f4f3a1eef7792e71938eff1433e24389b56c (diff) | |
download | tracifyjs-70474310f3ba7f2f4395117ad2d779ced016075b.tar.gz tracifyjs-70474310f3ba7f2f4395117ad2d779ced016075b.zip |
improve `unsafe` `evaluate` of `function` (#2936)
Miscellaneous
- simplify `run_code()` hack
-rw-r--r-- | lib/compress.js | 2 | ||||
-rw-r--r-- | test/sandbox.js | 14 |
2 files changed, 2 insertions, 14 deletions
diff --git a/lib/compress.js b/lib/compress.js index f3770cce..d1c21c78 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -2344,7 +2344,7 @@ merge(Compressor.prototype, { var fn = function() {}; fn.node = this; fn.toString = function() { - return this.node.print_to_string(); + return "function(){}"; }; return fn; } diff --git a/test/sandbox.js b/test/sandbox.js index b534613d..bef63df0 100644 --- a/test/sandbox.js +++ b/test/sandbox.js @@ -27,7 +27,6 @@ var FUNC_TOSTRING = [ "});", "Function.prototype.toString = function() {", " var id = 100000;", - " var toString = Function.prototype.toString;", " return function() {", " var n = this.name;", " if (!/^F[0-9]{6}N$/.test(n)) {", @@ -40,18 +39,7 @@ var FUNC_TOSTRING = [ " });", ] : [], [ " }", - " var body = toString.call(this);", - ' body = body.slice(body.indexOf("{") + 1, -1);', - ' if (/^(?:[\\s{}();,]|[0-9\\.]+|"[^"]*"|\\w+:|var [^=;]+|\\/\\/.*|\\/\\*[\\s\\S]*\\*\\/)*(?:$|return(?:$|;|\\n))/.test(body)) {', - ' body = "";', - " } else {", - ' body = n + "' + function() { - var s = ";"; - for (var i = 7; --i >= 0;) s += s; - return s; - }() + '";', - " }", - ' return "function(){" + body + "}";', + ' return "function(){}";', " };", "}();", ]).join("\n"); |