Skip to content

Instantly share code, notes, and snippets.

@mala
mala / jq_quickpatch.html
Created June 26, 2011 03:13 — forked from anonymous/jq_quickpatch.html
quick patch for jQuery selector XSS
<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]);