From: John Resig Date: Wed, 22 Aug 2007 06:19:22 +0000 (+0000) Subject: Fixed use of eval() and new Function() to work within the correct scope (and not... X-Git-Url: http://git.asbjorn.it/?a=commitdiff_plain;h=f2f399dcd552e73f68c9e8adfe26ef7995724cb3;hp=fc3e180465a88558321b6550ac4692d7cc4b281f;p=jquery.git Fixed use of eval() and new Function() to work within the correct scope (and not throw errors). --- diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js index 7c0562a..9bcec93 100644 --- a/src/jquery/jquery.js +++ b/src/jquery/jquery.js @@ -1857,7 +1857,7 @@ jQuery.extend({ // If a string is passed in for the function, make a function // for it (a handy shortcut) if ( typeof fn == "string" ) - fn = eval("function(a,i){return " + fn + "}"); + fn = eval("false||function(a,i){return " + fn + "}"); var result = []; @@ -1911,7 +1911,7 @@ jQuery.extend({ // If a string is passed in for the function, make a function // for it (a handy shortcut) if ( typeof fn == "string" ) - fn = eval("function(a){return " + fn + "}"); + fn = eval("false||function(a){return " + fn + "}"); var result = []; diff --git a/src/selector/selector.js b/src/selector/selector.js index cf23111..bd8c791 100644 --- a/src/selector/selector.js +++ b/src/selector/selector.js @@ -405,7 +405,7 @@ jQuery.extend({ f = jQuery.expr[m[1]][m[2]]; // Build a custom macro to enclose it - eval("f = function(a,i){return " + f + "}"); + f = eval("false||function(a,i){return " + f + "}"); // Execute it against the current filter r = jQuery.grep( r, f, not );