1
1
/*!
2
- * jQuery Migrate - v1.1 .1 - 2013-02-16
2
+ * jQuery Migrate - v1.2 .1 - 2013-05-08
3
3
* https://github.com/jquery/jquery-migrate
4
4
* Copyright 2005, 2013 jQuery Foundation, Inc. and other contributors; Licensed MIT
5
5
*/
@@ -17,8 +17,8 @@ jQuery.migrateWarnings = [];
17
17
// jQuery.migrateMute = false;
18
18
19
19
// Show a message on the console so devs know we're active
20
- if ( ! jQuery . migrateMute && window . console && console . log ) {
21
- console . log ( "JQMIGRATE: Logging is active" ) ;
20
+ if ( ! jQuery . migrateMute && window . console && window . console . log ) {
21
+ window . console . log ( "JQMIGRATE: Logging is active" ) ;
22
22
}
23
23
24
24
// Set to false to disable traces that appear with warnings
@@ -33,10 +33,11 @@ jQuery.migrateReset = function() {
33
33
} ;
34
34
35
35
function migrateWarn ( msg ) {
36
+ var console = window . console ;
36
37
if ( ! warnedAbout [ msg ] ) {
37
38
warnedAbout [ msg ] = true ;
38
39
jQuery . migrateWarnings . push ( msg ) ;
39
- if ( window . console && console . warn && ! jQuery . migrateMute ) {
40
+ if ( console && console . warn && ! jQuery . migrateMute ) {
40
41
console . warn ( "JQMIGRATE: " + msg ) ;
41
42
if ( jQuery . migrateTrace && console . trace ) {
42
43
console . trace ( ) ;
@@ -189,26 +190,35 @@ jQuery.attrHooks.value = {
189
190
var matched , browser ,
190
191
oldInit = jQuery . fn . init ,
191
192
oldParseJSON = jQuery . parseJSON ,
192
- // Note this does NOT include the #9521 XSS fix from 1.7!
193
- rquickExpr = / ^ (?: [ ^ < ] * ( < [ \w \W ] + > ) [ ^ > ] * | # ( [ \w \- ] * ) ) $ / ;
193
+ // Note: XSS check is done below after string is trimmed
194
+ rquickExpr = / ^ ( [ ^ < ] * ) ( < [ \w \W ] + > ) ( [ ^ > ] * ) $ / ;
194
195
195
196
// $(html) "looks like html" rule change
196
197
jQuery . fn . init = function ( selector , context , rootjQuery ) {
197
198
var match ;
198
199
199
200
if ( selector && typeof selector === "string" && ! jQuery . isPlainObject ( context ) &&
200
- ( match = rquickExpr . exec ( selector ) ) && match [ 1 ] ) {
201
+ ( match = rquickExpr . exec ( jQuery . trim ( selector ) ) ) && match [ 0 ] ) {
201
202
// This is an HTML string according to the "old" rules; is it still?
202
203
if ( selector . charAt ( 0 ) !== "<" ) {
203
204
migrateWarn ( "$(html) HTML strings must start with '<' character" ) ;
204
205
}
206
+ if ( match [ 3 ] ) {
207
+ migrateWarn ( "$(html) HTML text after last tag is ignored" ) ;
208
+ }
209
+ // Consistently reject any HTML-like string starting with a hash (#9521)
210
+ // Note that this may break jQuery 1.6.x code that otherwise would work.
211
+ if ( match [ 0 ] . charAt ( 0 ) === "#" ) {
212
+ migrateWarn ( "HTML string cannot start with a '#' character" ) ;
213
+ jQuery . error ( "JQMIGRATE: Invalid selector string (XSS)" ) ;
214
+ }
205
215
// Now process using loose rules; let pre-1.8 play too
206
216
if ( context && context . context ) {
207
217
// jQuery object as context; parseHTML expects a DOM object
208
218
context = context . context ;
209
219
}
210
220
if ( jQuery . parseHTML ) {
211
- return oldInit . call ( this , jQuery . parseHTML ( jQuery . trim ( selector ) , context , true ) ,
221
+ return oldInit . call ( this , jQuery . parseHTML ( match [ 2 ] , context , true ) ,
212
222
context , rootjQuery ) ;
213
223
}
214
224
}
@@ -508,4 +518,4 @@ jQuery.each( ajaxEvents.split("|"),
508
518
) ;
509
519
510
520
511
- } ) ( jQuery , window ) ;
521
+ } ) ( jQuery , window ) ;
0 commit comments