improve unsafe evaluate of function (#2936)
Miscellaneous - simplify `run_code()` hack
This commit is contained in:
@@ -2344,7 +2344,7 @@ merge(Compressor.prototype, {
|
|||||||
var fn = function() {};
|
var fn = function() {};
|
||||||
fn.node = this;
|
fn.node = this;
|
||||||
fn.toString = function() {
|
fn.toString = function() {
|
||||||
return this.node.print_to_string();
|
return "function(){}";
|
||||||
};
|
};
|
||||||
return fn;
|
return fn;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ var FUNC_TOSTRING = [
|
|||||||
"});",
|
"});",
|
||||||
"Function.prototype.toString = function() {",
|
"Function.prototype.toString = function() {",
|
||||||
" var id = 100000;",
|
" var id = 100000;",
|
||||||
" var toString = Function.prototype.toString;",
|
|
||||||
" return function() {",
|
" return function() {",
|
||||||
" var n = this.name;",
|
" var n = this.name;",
|
||||||
" if (!/^F[0-9]{6}N$/.test(n)) {",
|
" if (!/^F[0-9]{6}N$/.test(n)) {",
|
||||||
@@ -40,18 +39,7 @@ var FUNC_TOSTRING = [
|
|||||||
" });",
|
" });",
|
||||||
] : [], [
|
] : [], [
|
||||||
" }",
|
" }",
|
||||||
" var body = toString.call(this);",
|
' return "function(){}";',
|
||||||
' 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 + "}";',
|
|
||||||
" };",
|
" };",
|
||||||
"}();",
|
"}();",
|
||||||
]).join("\n");
|
]).join("\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user