globalEval
-
-
Save leecade/1272010 to your computer and use it in GitHub Desktop.
globalEval
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ( | |
a, //string | |
b //placeholder | |
){ | |
b = window, | |
'' + a === a && /\S/.test(a) && //check the arguments(not only NUL) | |
(b.execScript || //IE || chrome | |
function() {b["eval"].call(b, a) //fix the eval's scope | |
})(a) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function (a,b){b=window,""+a===a&&/\S/.test(a)&&(b.execScript||function(){b.eval.call(b,a)})(a)} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "globalEval", | |
"description": "globalEval", | |
"keywords": [ | |
"globalEval", | |
"javascript", | |
"斯人", | |
"leecade" | |
] | |
} |
I think that is superfluous, `''+a===a`` is enough to prevent NULL.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks tsaniel, /\S/.test used to make sure that not only NUL