-
-
Save mala/1047182 to your computer and use it in GitHub Desktop.
quick patch for jQuery selector XSS
This file contains hidden or 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
<script type="text/javascript"> | |
// http://ma.la/jquery_xss/ | |
(function($){ | |
var _init = $.fn.init; | |
$.fn.init = function(selector, context, rootjQuery){ | |
// note: only block "#<img>", "a[href=<img onerror=...>]" still work. | |
if( typeof arguments[ 0 ] == "string" && /^#.*</.test( arguments[ 0 ] ) ){ | |
throw new Error( "selector error" ); | |
} | |
// console.log(arguments[0]); | |
return _init.apply(this, arguments); | |
}; | |
$.fn.init.prototype = _init.prototype; | |
})(jQuery); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment