Skip to content

Commit 5affbad

Browse files
committed
Merge branch '1.3.3-sec' into 1.4.5-sec
2 parents 9b20df0 + f400223 commit 5affbad

File tree

6 files changed

+39
-14
lines changed

6 files changed

+39
-14
lines changed

component.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name" : "jquery",
3-
"version" : "1.4.4",
3+
"version" : "1.4.5-sec",
44
"main" : "./jquery.js",
55
"dependencies": {
66
}

src/ajax.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
(function( jQuery ) {
22

33
var jsc = jQuery.now(),
4-
rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
4+
rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*< *\/ *script *>?/gi,
55
rselectTextarea = /^(?:select|textarea)/i,
66
rinput = /^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
77
rnoContent = /^(?:GET|HEAD)$/,

src/core.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ var jQuery = function( selector, context ) {
1616
rootjQuery,
1717

1818
// A simple way to check for HTML strings or ID strings
19-
// (both of which we optimize for)
20-
quickExpr = /^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]+)$)/,
19+
// Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
20+
// Strict HTML recognition (#11290: must start with <)
21+
quickExpr = /^(?:(<[\w\W]+>)[^>]*|#([\w-]*))$/,
2122

2223
// Is it a simple selector
2324
isSimple = /^.[^:#\[\.,]*$/,
@@ -344,8 +345,9 @@ jQuery.extend = jQuery.fn.extend = function() {
344345
src = target[ name ];
345346
copy = options[ name ];
346347

348+
// Prevent Object.prototype pollution
347349
// Prevent never-ending loop
348-
if ( target === copy ) {
350+
if ( name === "__proto__" || target === copy ) {
349351
continue;
350352
}
351353

src/manipulation.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
44
rleadingWhitespace = /^\s+/,
5-
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
65
rtagName = /<([\w:]+)/,
76
rtbody = /<tbody/i,
87
rhtml = /<|&#?\w+;/,
@@ -11,7 +10,6 @@ var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
1110
rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
1211
raction = /\=([^="'>\s]+\/)>/g,
1312
wrapMap = {
14-
option: [ 1, "<select multiple='multiple'>", "</select>" ],
1513
legend: [ 1, "<fieldset>", "</fieldset>" ],
1614
thead: [ 1, "<table>", "</table>" ],
1715
tr: [ 2, "<table><tbody>", "</tbody></table>" ],
@@ -21,7 +19,6 @@ var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
2119
_default: [ 0, "", "" ]
2220
};
2321

24-
wrapMap.optgroup = wrapMap.option;
2522
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
2623
wrapMap.th = wrapMap.td;
2724

@@ -235,8 +232,6 @@ jQuery.fn.extend({
235232
(jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) &&
236233
!wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) {
237234

238-
value = value.replace(rxhtmlTag, "<$1></$2>");
239-
240235
try {
241236
for ( var i = 0, l = this.length; i < l; i++ ) {
242237
// Remove element nodes and prevent memory leaks
@@ -483,8 +478,6 @@ jQuery.extend({
483478
elem = context.createTextNode( elem );
484479

485480
} else if ( typeof elem === "string" ) {
486-
// Fix "XHTML"-style tags in all browsers
487-
elem = elem.replace(rxhtmlTag, "<$1></$2>");
488481

489482
// Trim whitespace, otherwise indexOf won't work as expected
490483
var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(),

test/unit/core.js

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ test("jQuery()", function() {
5555
var img = jQuery("<img/>");
5656
equals( img.length, 1, "Correct number of elements generated for img" );
5757
equals( img.parent().length, 0, "Make sure that the generated HTML has no parent." );
58-
var div = jQuery("<div/><hr/><code/><b/>");
58+
var div = jQuery("<div></div><hr><code></code><b></b>");
5959
equals( div.length, 4, "Correct number of elements generated for div hr code b" );
6060
equals( div.parent().length, 0, "Make sure that the generated HTML has no parent." );
6161

@@ -499,6 +499,36 @@ test("jQuery('html', context)", function() {
499499
equals($span.length, 1, "Verify a span created with a div context works, #1763");
500500
});
501501

502+
test("XSS via location.hash", function() {
503+
expect(1);
504+
505+
stop();
506+
jQuery._check9521 = function(x){
507+
ok( x, "script called from #id-like selector with inline handler" );
508+
jQuery("#check9521").remove();
509+
delete jQuery._check9521;
510+
};
511+
512+
var $eCheck9521 = jQuery( '#<img id="check9521" src="no-such-.gif" onerror="jQuery._check9521(false)">' );
513+
514+
if($eCheck9521.length) {
515+
$eCheck9521.appendTo("#main");
516+
}
517+
else {
518+
jQuery._check9521(true);
519+
}
520+
521+
start();
522+
523+
});
524+
525+
test( "jQuery.extend( true, ... ) Object.prototype pollution", function( assert ) {
526+
expect( 1 );
527+
528+
jQuery.extend( true, {}, JSON.parse( "{\"__proto__\": {\"devMode\": true}}" ) );
529+
ok( !( "devMode" in {} ), "Object.prototype not polluted" );
530+
} );
531+
502532
if ( !isLocal ) {
503533
test("jQuery(selector, xml).text(str) - Loaded via XML document", function() {
504534
expect(2);

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.4.4
1+
1.4.5-sec

0 commit comments

Comments
 (0)