Skip id regex check when large html strings are passed to the jQuery constructor (#7990).

This commit is contained in:
carpie 2011-01-19 17:37:31 -06:00 committed by Dave Methvin
parent ceaf093942
commit e0856738e6
2 changed files with 20 additions and 2 deletions

View file

@ -96,7 +96,12 @@ jQuery.fn = jQuery.prototype = {
// Handle HTML strings
if ( typeof selector === "string" ) {
// Are we dealing with HTML string or an ID?
match = quickExpr.exec( selector );
if ( selector.length > 1024 ) {
// Assume very large strings are HTML and skip the regex check
match = [ null, selector, null ];
} else {
match = quickExpr.exec( selector );
}
// Verify a match, and that no context was specified for #id
if ( match && (match[1] || !context) ) {