Skip to content

fix all CVEs in 1.4.4 #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: 1.4.4-branch
Choose a base branch
from
2 changes: 1 addition & 1 deletion component.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name" : "jquery",
"version" : "1.4.4",
"version" : "1.4.5-sec",
"main" : "./jquery.js",
"dependencies": {
}
Expand Down
25 changes: 10 additions & 15 deletions jquery.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* jQuery JavaScript Library v1.4.4
* jQuery JavaScript Library v1.4.5-sec
* http://jquery.com/
*
* Copyright 2010, John Resig
Expand All @@ -11,7 +11,7 @@
* Copyright 2010, The Dojo Foundation
* Released under the MIT, BSD, and GPL Licenses.
*
* Date: Thu Nov 11 19:04:53 2010 -0500
* Date: Thu Feb 15 16:39:20 2024 -0600
*/
(function( window, undefined ) {

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

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

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

// The current version of jQuery being used
jquery: "1.4.4",
jquery: "1.4.5-sec",

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

// Prevent Object.prototype pollution
// Prevent never-ending loop
if ( target === copy ) {
if ( name === "__proto__" || target === copy ) {
continue;
}

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

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

wrapMap.optgroup = wrapMap.option;
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
wrapMap.th = wrapMap.td;

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

value = value.replace(rxhtmlTag, "<$1></$2>");

try {
for ( var i = 0, l = this.length; i < l; i++ ) {
// Remove element nodes and prevent memory leaks
Expand Down Expand Up @@ -5104,8 +5101,6 @@ jQuery.extend({
elem = context.createTextNode( elem );

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

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


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

// If the type is "script", eval it in global context
} else if ( type === "script" || !type && ct.indexOf("javascript") >= 0 ) {
} else if ( type === "script" ) {
jQuery.globalEval( data );
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/ajax.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(function( jQuery ) {

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

// If the type is "script", eval it in global context
} else if ( type === "script" || !type && ct.indexOf("javascript") >= 0 ) {
} else if ( type === "script" ) {
jQuery.globalEval( data );
}
}
Expand Down
8 changes: 5 additions & 3 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ var jQuery = function( selector, context ) {
rootjQuery,

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

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

// Prevent Object.prototype pollution
// Prevent never-ending loop
if ( target === copy ) {
if ( name === "__proto__" || target === copy ) {
continue;
}

Expand Down
7 changes: 0 additions & 7 deletions src/manipulation.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

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

wrapMap.optgroup = wrapMap.option;
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
wrapMap.th = wrapMap.td;

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

value = value.replace(rxhtmlTag, "<$1></$2>");

try {
for ( var i = 0, l = this.length; i < l; i++ ) {
// Remove element nodes and prevent memory leaks
Expand Down Expand Up @@ -483,8 +478,6 @@ jQuery.extend({
elem = context.createTextNode( elem );

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

// Trim whitespace, otherwise indexOf won't work as expected
var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(),
Expand Down
19 changes: 17 additions & 2 deletions test/unit/ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -989,8 +989,8 @@ test("jQuery.ajax() - malformed JSON", function() {
});
});

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

stop();

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

test("jQuery.ajax() - execute script by content-type if dataType is script", function() {
expect(1);

stop();

jQuery.ajax({
url: "data/script.php",
data: { header: "script" },
success: function() {
start();
},
dataType: 'script'
});
});

test("jQuery.ajax() - json by content-type", function() {
expect(5);

Expand Down
32 changes: 31 additions & 1 deletion test/unit/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ test("jQuery()", function() {
var img = jQuery("<img/>");
equals( img.length, 1, "Correct number of elements generated for img" );
equals( img.parent().length, 0, "Make sure that the generated HTML has no parent." );
var div = jQuery("<div/><hr/><code/><b/>");
var div = jQuery("<div></div><hr><code></code><b></b>");
equals( div.length, 4, "Correct number of elements generated for div hr code b" );
equals( div.parent().length, 0, "Make sure that the generated HTML has no parent." );

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

test("XSS via location.hash", function() {
expect(1);

stop();
jQuery._check9521 = function(x){
ok( x, "script called from #id-like selector with inline handler" );
jQuery("#check9521").remove();
delete jQuery._check9521;
};

var $eCheck9521 = jQuery( '#<img id="check9521" src="no-such-.gif" onerror="jQuery._check9521(false)"' );

if($eCheck9521.length) {
$eCheck9521.appendTo("#main");
}
else {
jQuery._check9521(true);
}

start();

});

test( "jQuery.extend( true, ... ) Object.prototype pollution", function( assert ) {
expect( 1 );

jQuery.extend( true, {}, JSON.parse( "{\"__proto__\": {\"devMode\": true}}" ) );
ok( !( "devMode" in {} ), "Object.prototype not polluted" );
} );

if ( !isLocal ) {
test("jQuery(selector, xml).text(str) - Loaded via XML document", function() {
expect(2);
Expand Down
2 changes: 1 addition & 1 deletion test/unit/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ test("css(String|Hash)", function() {
equals( div.css("width"), "4px", "Width on disconnected node." );
equals( div.css("height"), "4px", "Height on disconnected node." );

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");
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");

equals( div2.find("input").css("height"), "20px", "Height on hidden input." );
equals( div2.find("textarea").css("height"), "20px", "Height on hidden textarea." );
Expand Down
2 changes: 1 addition & 1 deletion test/unit/manipulation.js
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ var testHtml = function(valueObj) {
}
ok( pass, "Set HTML" );

div = jQuery("<div/>").html( valueObj('<div id="parent_1"><div id="child_1"/></div><div id="parent_2"/>') );
div = jQuery("<div>").html( valueObj("<div id='parent_1'><div id='child_1'></div></div><div id='parent_2'></div>") );

equals( div.children().length, 2, "Make sure two child nodes exist." );
equals( div.children().children().length, 1, "Make sure that a grandchild exists." );
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.4
1.4.5-sec