Created
April 26, 2012 13:23
-
-
Save mala/2499522 to your computer and use it in GitHub Desktop.
jQuery XSS patch
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(){ | |
jQuery.fn.__init = jQuery.fn.init; | |
var old_expr = /^(?:[^<]*(<[\w\W]+>)[^>]*$)/; | |
var strict_expr = /^\s*</; | |
jQuery.fn.init = function(selector, context, rootjQuery){ | |
if (typeof selector === "string") { | |
// console.log(selector); | |
if (old_expr.test(selector) && !strict_expr.test(selector)) { | |
throw 'Syntax error, html string must start with "<"'; | |
} | |
} | |
return new jQuery.fn.__init(selector, context, rootjQuery); | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment