Skip to content

Commit 7b89292

Browse files
committed
Merge branch '1.7.3-sec' into 1.8.4-sec
2 parents 2d4663e + d412a7b commit 7b89292

File tree

12 files changed

+102
-24
lines changed

12 files changed

+102
-24
lines changed

.gitmodules

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[submodule "src/sizzle"]
22
path = src/sizzle
3-
url = git://github.com/jquery/sizzle.git
3+
url = https://github.com/jquery/sizzle.git
44
[submodule "test/qunit"]
55
path = test/qunit
6-
url = git://github.com/jquery/qunit.git
6+
url = https://github.com/qunitjs/qunit.git

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.8.3",
3+
"version": "1.8.4-sec",
44
"description": "jQuery component",
55
"keywords": [
66
"jquery",

src/ajax.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ var
1010
rnoContent = /^(?:GET|HEAD)$/,
1111
rprotocol = /^\/\//,
1212
rquery = /\?/,
13-
rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
13+
rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*< *\/ *script *>?/gi,
1414
rts = /([?&])_=[^&]*/,
1515
rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,
1616

src/ajax/script.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
// Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
2+
jQuery.ajaxPrefilter( function( s ) {
3+
if ( s.crossDomain ) {
4+
s.contents.script = false;
5+
}
6+
} );
7+
18
// Install script dataType
29
jQuery.ajaxSetup({
310
accepts: {

src/core.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ var
4242

4343
// A simple way to check for HTML strings
4444
// Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
45-
rquickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,
45+
// Strict HTML recognition (#11290: must start with <)
46+
rquickExpr = /^(?:(<[\w\W]+>)[^>]*|#([\w\-]*))$/,
4647

4748
// Match a standalone tag
4849
rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/,
@@ -308,8 +309,9 @@ jQuery.extend = jQuery.fn.extend = function() {
308309
src = target[ name ];
309310
copy = options[ name ];
310311

312+
// Prevent Object.prototype pollution
311313
// Prevent never-ending loop
312-
if ( target === copy ) {
314+
if ( name === "__proto__" || target === copy ) {
313315
continue;
314316
}
315317

src/manipulation.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figca
1616
"header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
1717
rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
1818
rleadingWhitespace = /^\s+/,
19-
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
2019
rtagName = /<([\w:]+)/,
2120
rtbody = /<tbody/i,
2221
rhtml = /<|&#?\w+;/,
@@ -29,7 +28,6 @@ var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figca
2928
rscriptType = /\/(java|ecma)script/i,
3029
rcleanScript = /^\s*<!(?:\[CDATA\[|\-\-)|[\]\-]{2}>\s*$/g,
3130
wrapMap = {
32-
option: [ 1, "<select multiple='multiple'>", "</select>" ],
3331
legend: [ 1, "<fieldset>", "</fieldset>" ],
3432
thead: [ 1, "<table>", "</table>" ],
3533
tr: [ 2, "<table><tbody>", "</tbody></table>" ],
@@ -41,7 +39,6 @@ var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figca
4139
safeFragment = createSafeFragment( document ),
4240
fragmentDiv = safeFragment.appendChild( document.createElement("div") );
4341

44-
wrapMap.optgroup = wrapMap.option;
4542
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
4643
wrapMap.th = wrapMap.td;
4744

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

237-
value = value.replace( rxhtmlTag, "<$1></$2>" );
238-
239234
try {
240235
for (; i < l; i++ ) {
241236
// Remove element nodes and prevent memory leaks
@@ -667,9 +662,6 @@ jQuery.extend({
667662
div = context.createElement("div");
668663
safe.appendChild( div );
669664

670-
// Fix "XHTML"-style tags in all browsers
671-
elem = elem.replace(rxhtmlTag, "<$1></$2>");
672-
673665
// Go to html and back, then peel off extra wrappers
674666
tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase();
675667
wrap = wrapMap[ tag ] || wrapMap._default;

test/src

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../src

test/unit/ajax.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,70 @@ test("jQuery.ajax() - success callbacks - (url, options) syntax", function() {
6767
}, 13);
6868
});
6969

70+
test( "jQuery.ajax() - do not execute js (crossOrigin) 1", 2, function() {
71+
72+
jQuery.ajaxSetup({ timeout: 0 });
73+
74+
stop();
75+
76+
setTimeout(function(){
77+
jQuery.ajax({
78+
url: url( "data/script.php?header=ecma" ),
79+
crossDomain: true,
80+
success: function() {
81+
ok( true, "success" );
82+
},
83+
complete: function() {
84+
ok( true, "complete" );
85+
start();
86+
}
87+
});
88+
}, 13);
89+
} );
90+
91+
test( "jQuery.ajax() - execute js for crossOrigin when dataType option is provided", 3, function() {
92+
93+
jQuery.ajaxSetup({ timeout: 0 });
94+
95+
stop();
96+
97+
setTimeout(function(){
98+
jQuery.ajax({
99+
url: url( "data/script.php?header=ecma" ),
100+
crossDomain: true,
101+
dataType: "script",
102+
success: function() {
103+
ok( true, "success" );
104+
},
105+
complete: function() {
106+
ok( true, "complete" );
107+
start();
108+
}
109+
});
110+
}, 13);
111+
} );
112+
113+
test( "jQuery.ajax() - do not execute js (crossOrigin) 2", 2, function() {
114+
115+
jQuery.ajaxSetup({ timeout: 0 });
116+
117+
stop();
118+
119+
setTimeout(function(){
120+
jQuery.ajax({
121+
url: url( "data/script.php" ),
122+
crossDomain: true,
123+
success: function() {
124+
ok( true, "success" );
125+
},
126+
complete: function() {
127+
ok( true, "complete" );
128+
start();
129+
}
130+
});
131+
}, 13);
132+
} );
133+
70134
test("jQuery.ajax() - success callbacks (late binding)", function() {
71135
expect( 8 );
72136

test/unit/core.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ test("jQuery()", function() {
2424
main = jQuery("#qunit-fixture"),
2525
code = jQuery("<code/>"),
2626
img = jQuery("<img/>"),
27-
div = jQuery("<div/><hr/><code/><b/>"),
27+
div = jQuery("<div></div><hr><code></code><b></b>"),
2828
exec = false,
2929
lng = "",
30-
expected = 26,
30+
expected = 24,
3131
attrObj = {
3232
"click": function() { ok( exec, "Click executed." ); },
3333
"text": "test",
@@ -139,15 +139,13 @@ test("jQuery()", function() {
139139
// manually clean up detached elements
140140
elem.remove();
141141

142-
equal( jQuery(" <div/> ").length, 1, "Make sure whitespace is trimmed." );
143-
equal( jQuery(" a<div/>b ").length, 1, "Make sure whitespace and other characters are trimmed." );
142+
equal( jQuery("<div></div> ").length, 1, "Make sure whitespace is trimmed." );
144143

145144
for ( i = 0; i < 128; i++ ) {
146145
lng += "12345678";
147146
}
148147

149-
equal( jQuery(" <div>" + lng + "</div> ").length, 1, "Make sure whitespace is trimmed on long strings." );
150-
equal( jQuery(" a<div>" + lng + "</div>b ").length, 1, "Make sure whitespace and other characters are trimmed on long strings." );
148+
equal( jQuery("<div>" + lng + "</div> ").length, 1, "Make sure whitespace is trimmed on long strings." );
151149
});
152150

153151
test("selector state", function() {
@@ -664,6 +662,13 @@ test("jQuery('html', context)", function() {
664662
equal($span.length, 1, "Verify a span created with a div context works, #1763");
665663
});
666664

665+
test( "jQuery.extend( true, ... ) Object.prototype pollution", function( assert ) {
666+
expect( 1 );
667+
668+
jQuery.extend( true, {}, JSON.parse( "{\"__proto__\": {\"devMode\": true}}" ) );
669+
ok( !( "devMode" in {} ), "Object.prototype not polluted" );
670+
} );
671+
667672
test("jQuery(selector, xml).text(str) - Loaded via XML document", function() {
668673
expect(2);
669674

@@ -980,6 +985,13 @@ test("jQuery.extend(Object, Object)", function() {
980985
deepEqual( options2, options2Copy, "Check if not modified: options2 must not be modified" );
981986
});
982987

988+
QUnit.test( "jQuery.extend( true, ... ) Object.prototype pollution", function( assert ) {
989+
expect( 1 );
990+
991+
jQuery.extend( true, {}, JSON.parse( "{\"__proto__\": {\"devMode\": true}}" ) );
992+
ok( !( "devMode" in {} ), "Object.prototype not polluted" );
993+
} );
994+
983995
test("jQuery.each(Object,Function)", function() {
984996
expect(14);
985997
jQuery.each( [0,1,2], function(i, n){

test/unit/css.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ test("css(String|Hash)", function() {
3131
equal( div.css("width"), "4px", "Width on disconnected node." );
3232
equal( div.css("height"), "4px", "Height on disconnected node." );
3333

34-
var div2 = jQuery( "<div style='display:none;'><input type='text' style='height:20px;'/><textarea style='height:20px;'/><div style='height:20px;'></div></div>").appendTo("body");
34+
var div2 = jQuery( "<div style='display:none;'><input type='text' style='height:20px;'/><textarea style='height:20px;'></textarea><div style='height:20px;'></div></div>").appendTo("body");
3535

3636
equal( div2.find("input").css("height"), "20px", "Height on hidden input." );
3737
equal( div2.find("textarea").css("height"), "20px", "Height on hidden textarea." );

0 commit comments

Comments
 (0)