11/*!
2- * jQuery Migrate - v1.2.0 - 2013-05-01
2+ * jQuery Migrate - v1.2.1 - 2013-05-08
33 * https://github.com/jquery/jquery-migrate
44 * Copyright 2005, 2013 jQuery Foundation, Inc. and other contributors; Licensed MIT
55 */
@@ -190,26 +190,25 @@ jQuery.attrHooks.value = {
190190var matched , browser ,
191191 oldInit = jQuery . fn . init ,
192192 oldParseJSON = jQuery . parseJSON ,
193- rignoreText = / ^ [ ^ < ] * ( .* ?) [ ^ > ] * $ / ,
194- // Note this does NOT include the #9521 XSS fix from 1.7!
195- rquickExpr = / ^ [ ^ < ] * < [ \w \W ] + > [ ^ > ] * $ / ;
193+ // Note: XSS check is done below after string is trimmed
194+ rquickExpr = / ^ ( [ ^ < ] * ) ( < [ \w \W ] + > ) ( [ ^ > ] * ) $ / ;
196195
197196// $(html) "looks like html" rule change
198197jQuery . fn . init = function ( selector , context , rootjQuery ) {
199198 var match ;
200199
201200 if ( selector && typeof selector === "string" && ! jQuery . isPlainObject ( context ) &&
202- ( match = rquickExpr . exec ( selector ) ) && match [ 0 ] ) {
201+ ( match = rquickExpr . exec ( jQuery . trim ( selector ) ) ) && match [ 0 ] ) {
203202 // This is an HTML string according to the "old" rules; is it still?
204203 if ( selector . charAt ( 0 ) !== "<" ) {
205204 migrateWarn ( "$(html) HTML strings must start with '<' character" ) ;
206205 }
207- if ( selector . charAt ( selector . length - 1 ) !== ">" ) {
206+ if ( match [ 3 ] ) {
208207 migrateWarn ( "$(html) HTML text after last tag is ignored" ) ;
209208 }
210209 // Consistently reject any HTML-like string starting with a hash (#9521)
211210 // Note that this may break jQuery 1.6.x code that otherwise would work.
212- if ( jQuery . trim ( selector ) . charAt ( 0 ) === "#" ) {
211+ if ( match [ 0 ] . charAt ( 0 ) === "#" ) {
213212 migrateWarn ( "HTML string cannot start with a '#' character" ) ;
214213 jQuery . error ( "JQMIGRATE: Invalid selector string (XSS)" ) ;
215214 }
@@ -219,8 +218,7 @@ jQuery.fn.init = function( selector, context, rootjQuery ) {
219218 context = context . context ;
220219 }
221220 if ( jQuery . parseHTML ) {
222- match = rignoreText . exec ( selector ) ;
223- return oldInit . call ( this , jQuery . parseHTML ( match [ 1 ] || selector , context , true ) ,
221+ return oldInit . call ( this , jQuery . parseHTML ( match [ 2 ] , context , true ) ,
224222 context , rootjQuery ) ;
225223 }
226224 }
0 commit comments