Skip to content

Commit 8895d73

Browse files
committed
🔒️ fix CVE-2020-11023
1 parent 1852f48 commit 8895d73

File tree

4 files changed

+30
-14
lines changed

4 files changed

+30
-14
lines changed

src/manipulation/support.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ define( [
2626
// Make sure textarea (and checkbox) defaultValue is properly cloned
2727
div.innerHTML = "<textarea>x</textarea>";
2828
support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
29+
30+
// Support: IE <=9 only
31+
// IE <=9 replaces <option> tags with their contents when inserted outside of
32+
// the select element.
33+
div.innerHTML = "<option></option>";
34+
support.option = !!div.lastChild;
2935
} )();
3036

3137
return support;

src/manipulation/wrapMap.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
define( function() {
1+
define( [
2+
"./support"
3+
], function( support ) {
24

35
// We have to close these tags to support XHTML (#13200)
46
var wrapMap = {
57

6-
// Support: IE9
7-
option: [ 1, "<select multiple='multiple'>", "</select>" ],
8-
98
// XHTML parsers do not magically insert elements in the
109
// same way that tag soup parsers do. So we cannot shorten
1110
// this by omitting <tbody> or other required elements.
@@ -17,11 +16,13 @@ var wrapMap = {
1716
_default: [ 0, "", "" ]
1817
};
1918

20-
// Support: IE9
21-
wrapMap.optgroup = wrapMap.option;
22-
2319
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
2420
wrapMap.th = wrapMap.td;
2521

22+
// Support: IE <=9 only
23+
if ( !support.option ) {
24+
wrapMap.optgroup = wrapMap.option = [ 1, "<select multiple='multiple'>", "</select>" ];
25+
}
26+
2627
return wrapMap;
2728
} );

test/unit/manipulation.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2558,17 +2558,13 @@ QUnit.test( "Make sure specific elements with content created correctly (#13232)
25582558
} );
25592559

25602560
QUnit.test( "Validate creation of multiple quantities of certain elements (#13818)", function( assert ) {
2561-
assert.expect( 44 );
2561+
assert.expect( 22 );
25622562

25632563
var tags = [ "thead", "tbody", "tfoot", "colgroup", "col", "caption", "tr", "th", "td", "optgroup", "option" ];
25642564

25652565
jQuery.each( tags, function( index, tag ) {
2566-
jQuery( "<" + tag + "/><" + tag + "/>" ).each( function() {
2567-
assert.ok( jQuery.nodeName( this, tag ), tag + " empty elements created correctly" );
2568-
} );
2569-
2570-
jQuery( "<" + this + "></" + tag + "><" + tag + "></" + tag + ">" ).each( function() {
2571-
assert.ok( jQuery.nodeName( this, tag ), tag + " elements with closing tag created correctly" );
2566+
jQuery( "<" + tag + "></" + tag + "><" + tag + "></" + tag + ">" ).each( function() {
2567+
assert.ok( this.nodeName.toLowerCase() === tag, tag + " elements created correctly" );
25722568
} );
25732569
} );
25742570
} );

test/unit/support.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ testIframeWithCallback(
6767
"cors": true,
6868
"focusin": false,
6969
"noCloneChecked": true,
70+
"option": true,
7071
"optDisabled": true,
7172
"optSelected": true,
7273
"pixelMarginRight": true,
@@ -85,6 +86,7 @@ testIframeWithCallback(
8586
"cors": true,
8687
"focusin": false,
8788
"noCloneChecked": true,
89+
"option": true,
8890
"optDisabled": true,
8991
"optSelected": true,
9092
"pixelMarginRight": true,
@@ -142,6 +144,7 @@ testIframeWithCallback(
142144
"cors": true,
143145
"focusin": false,
144146
"noCloneChecked": true,
147+
"option": true,
145148
"optDisabled": true,
146149
"optSelected": true,
147150
"pixelMarginRight": true,
@@ -160,6 +163,7 @@ testIframeWithCallback(
160163
"cors": true,
161164
"focusin": false,
162165
"noCloneChecked": true,
166+
"option": true,
163167
"optDisabled": true,
164168
"optSelected": true,
165169
"pixelMarginRight": true,
@@ -178,6 +182,7 @@ testIframeWithCallback(
178182
"cors": true,
179183
"focusin": false,
180184
"noCloneChecked": true,
185+
"option": true,
181186
"optDisabled": true,
182187
"optSelected": true,
183188
"pixelMarginRight": true,
@@ -196,6 +201,7 @@ testIframeWithCallback(
196201
"cors": true,
197202
"focusin": false,
198203
"noCloneChecked": true,
204+
"option": true,
199205
"optDisabled": true,
200206
"optSelected": true,
201207
"pixelMarginRight": true,
@@ -214,6 +220,7 @@ testIframeWithCallback(
214220
"cors": true,
215221
"focusin": false,
216222
"noCloneChecked": true,
223+
"option": true,
217224
"optDisabled": true,
218225
"optSelected": true,
219226
"pixelMarginRight": false,
@@ -232,6 +239,7 @@ testIframeWithCallback(
232239
"cors": true,
233240
"focusin": false,
234241
"noCloneChecked": true,
242+
"option": true,
235243
"optDisabled": true,
236244
"optSelected": true,
237245
"pixelMarginRight": true,
@@ -250,6 +258,7 @@ testIframeWithCallback(
250258
"cors": true,
251259
"focusin": false,
252260
"noCloneChecked": true,
261+
"option": true,
253262
"optDisabled": true,
254263
"optSelected": true,
255264
"pixelMarginRight": true,
@@ -268,6 +277,7 @@ testIframeWithCallback(
268277
"cors": true,
269278
"focusin": false,
270279
"noCloneChecked": true,
280+
"option": true,
271281
"optDisabled": true,
272282
"optSelected": true,
273283
"pixelMarginRight": true,
@@ -286,6 +296,7 @@ testIframeWithCallback(
286296
"cors": true,
287297
"focusin": false,
288298
"noCloneChecked": true,
299+
"option": true,
289300
"optDisabled": true,
290301
"optSelected": true,
291302
"pixelMarginRight": true,
@@ -304,6 +315,7 @@ testIframeWithCallback(
304315
"cors": true,
305316
"focusin": false,
306317
"noCloneChecked": true,
318+
"option": true,
307319
"optDisabled": true,
308320
"optSelected": true,
309321
"pixelMarginRight": false,
@@ -322,6 +334,7 @@ testIframeWithCallback(
322334
"cors": true,
323335
"focusin": false,
324336
"noCloneChecked": true,
337+
"option": true,
325338
"optDisabled": false,
326339
"optSelected": true,
327340
"pixelMarginRight": true,

0 commit comments

Comments
 (0)