Skip to content

Commit 634d27d

Browse files
committed
🔒️ fix CVE-2015-9251
1 parent d0fef0a commit 634d27d

File tree

3 files changed

+28
-18
lines changed

3 files changed

+28
-18
lines changed

jquery.js

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* jQuery JavaScript Library v1.4.4
2+
* jQuery JavaScript Library v1.4.5-sec
33
* http://jquery.com/
44
*
55
* Copyright 2010, John Resig
@@ -11,7 +11,7 @@
1111
* Copyright 2010, The Dojo Foundation
1212
* Released under the MIT, BSD, and GPL Licenses.
1313
*
14-
* Date: Thu Nov 11 19:04:53 2010 -0500
14+
* Date: Thu Feb 15 16:39:20 2024 -0600
1515
*/
1616
(function( window, undefined ) {
1717

@@ -35,8 +35,9 @@ var jQuery = function( selector, context ) {
3535
rootjQuery,
3636

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

4142
// Is it a simple selector
4243
isSimple = /^.[^:#\[\.,]*$/,
@@ -211,7 +212,7 @@ jQuery.fn = jQuery.prototype = {
211212
selector: "",
212213

213214
// The current version of jQuery being used
214-
jquery: "1.4.4",
215+
jquery: "1.4.5-sec",
215216

216217
// The default length of a jQuery object is 0
217218
length: 0,
@@ -363,8 +364,9 @@ jQuery.extend = jQuery.fn.extend = function() {
363364
src = target[ name ];
364365
copy = options[ name ];
365366

367+
// Prevent Object.prototype pollution
366368
// Prevent never-ending loop
367-
if ( target === copy ) {
369+
if ( name === "__proto__" || target === copy ) {
368370
continue;
369371
}
370372

@@ -4623,7 +4625,6 @@ function winnow( elements, qualifier, keep ) {
46234625

46244626
var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
46254627
rleadingWhitespace = /^\s+/,
4626-
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
46274628
rtagName = /<([\w:]+)/,
46284629
rtbody = /<tbody/i,
46294630
rhtml = /<|&#?\w+;/,
@@ -4632,7 +4633,6 @@ var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
46324633
rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
46334634
raction = /\=([^="'>\s]+\/)>/g,
46344635
wrapMap = {
4635-
option: [ 1, "<select multiple='multiple'>", "</select>" ],
46364636
legend: [ 1, "<fieldset>", "</fieldset>" ],
46374637
thead: [ 1, "<table>", "</table>" ],
46384638
tr: [ 2, "<table><tbody>", "</tbody></table>" ],
@@ -4642,7 +4642,6 @@ var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
46424642
_default: [ 0, "", "" ]
46434643
};
46444644

4645-
wrapMap.optgroup = wrapMap.option;
46464645
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
46474646
wrapMap.th = wrapMap.td;
46484647

@@ -4856,8 +4855,6 @@ jQuery.fn.extend({
48564855
(jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) &&
48574856
!wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) {
48584857

4859-
value = value.replace(rxhtmlTag, "<$1></$2>");
4860-
48614858
try {
48624859
for ( var i = 0, l = this.length; i < l; i++ ) {
48634860
// Remove element nodes and prevent memory leaks
@@ -5104,8 +5101,6 @@ jQuery.extend({
51045101
elem = context.createTextNode( elem );
51055102

51065103
} else if ( typeof elem === "string" ) {
5107-
// Fix "XHTML"-style tags in all browsers
5108-
elem = elem.replace(rxhtmlTag, "<$1></$2>");
51095104

51105105
// Trim whitespace, otherwise indexOf won't work as expected
51115106
var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(),
@@ -5566,7 +5561,7 @@ if ( jQuery.expr && jQuery.expr.filters ) {
55665561

55675562

55685563
var jsc = jQuery.now(),
5569-
rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
5564+
rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*< *\/ *script *>?/gi,
55705565
rselectTextarea = /^(?:select|textarea)/i,
55715566
rinput = /^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
55725567
rnoContent = /^(?:GET|HEAD)$/,
@@ -6247,7 +6242,7 @@ jQuery.extend({
62476242
data = jQuery.parseJSON( data );
62486243

62496244
// If the type is "script", eval it in global context
6250-
} else if ( type === "script" || !type && ct.indexOf("javascript") >= 0 ) {
6245+
} else if ( type === "script" ) {
62516246
jQuery.globalEval( data );
62526247
}
62536248
}

src/ajax.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ jQuery.extend({
682682
data = jQuery.parseJSON( data );
683683

684684
// If the type is "script", eval it in global context
685-
} else if ( type === "script" || !type && ct.indexOf("javascript") >= 0 ) {
685+
} else if ( type === "script" ) {
686686
jQuery.globalEval( data );
687687
}
688688
}

test/unit/ajax.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -989,8 +989,8 @@ test("jQuery.ajax() - malformed JSON", function() {
989989
});
990990
});
991991

992-
test("jQuery.ajax() - script by content-type", function() {
993-
expect(1);
992+
test("jQuery.ajax() - do not execute script by content-type if dataType is not script", function() {
993+
expect(0);
994994

995995
stop();
996996

@@ -1003,6 +1003,21 @@ test("jQuery.ajax() - script by content-type", function() {
10031003
});
10041004
});
10051005

1006+
test("jQuery.ajax() - execute script by content-type if dataType is script", function() {
1007+
expect(1);
1008+
1009+
stop();
1010+
1011+
jQuery.ajax({
1012+
url: "data/script.php",
1013+
data: { header: "script" },
1014+
success: function() {
1015+
start();
1016+
},
1017+
dataType: 'script'
1018+
});
1019+
});
1020+
10061021
test("jQuery.ajax() - json by content-type", function() {
10071022
expect(5);
10081023

0 commit comments

Comments
 (0)