Skip to content

Commit 446d7fc

Browse files
committed
🔒️ fix CVE-2020-7656
1 parent a6dafff commit 446d7fc

File tree

4 files changed

+15
-20
lines changed

4 files changed

+15
-20
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.2.6",
3+
"version" : "1.2.7-sec",
44
"main" : "./jquery.js",
55
"dependencies": {
66
}

jquery.js

100755100644
Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
(function(){
22
/*
3-
* jQuery 1.2.6 - New Wave Javascript
3+
* jQuery 1.2.7-sec - New Wave Javascript
44
*
55
* Copyright (c) 2008 John Resig (jquery.com)
66
* Dual licensed under the MIT (MIT-LICENSE.txt)
77
* and GPL (GPL-LICENSE.txt) licenses.
88
*
9-
* $Date: 2008/05/26 $
10-
* $Rev: 5685 $
9+
* $Date$
10+
* $Rev$
1111
*/
1212

1313
// Map over jQuery in case of overwrite
@@ -21,8 +21,9 @@ var jQuery = window.jQuery = window.$ = function( selector, context ) {
2121
};
2222

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

2728
// Is it a simple selector
2829
isSimple = /^.[^:#\[\.]*$/,
@@ -55,13 +56,13 @@ jQuery.fn = jQuery.prototype = {
5556

5657
// HANDLE: $("#id")
5758
else {
58-
var elem = document.getElementById( match[3] );
59+
var elem = document.getElementById( match[2] );
5960

6061
// Make sure an element was located
6162
if ( elem ){
6263
// Handle the case where IE and Opera return items
6364
// by name instead of ID
64-
if ( elem.id != match[3] )
65+
if ( elem.id != match[2] )
6566
return jQuery().find( selector );
6667

6768
// Otherwise, we inject the element directly into the jQuery object
@@ -84,7 +85,7 @@ jQuery.fn = jQuery.prototype = {
8485
},
8586

8687
// The current version of jQuery being used
87-
jquery: "1.2.6",
88+
jquery: "1.2.7-sec",
8889

8990
// The number of elements contained in the matched element set
9091
size: function() {
@@ -576,8 +577,9 @@ jQuery.extend = jQuery.fn.extend = function() {
576577
for ( var name in options ) {
577578
var src = target[ name ], copy = options[ name ];
578579

580+
// Prevent Object.prototype pollution
579581
// Prevent never-ending loop
580-
if ( target === copy )
582+
if ( name === "__proto__" || target === copy )
581583
continue;
582584

583585
// Recurse if we're merging object values
@@ -952,13 +954,6 @@ jQuery.extend({
952954

953955
// Convert html string into DOM nodes
954956
if ( typeof elem == "string" ) {
955-
// Fix "XHTML"-style tags in all browsers
956-
elem = elem.replace(/(<(\w+)[^>]*?)\/>/g, function(all, front, tag){
957-
return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i) ?
958-
all :
959-
front + "></" + tag + ">";
960-
});
961-
962957
// Trim whitespace, otherwise indexOf won't work as expected
963958
var tags = jQuery.trim( elem ).toLowerCase(), div = context.createElement("div");
964959

@@ -2463,7 +2458,7 @@ jQuery.fn.extend({
24632458
jQuery("<div/>")
24642459
// inject the contents of the document in, removing the scripts
24652460
// to avoid any 'Permission Denied' errors in IE
2466-
.append(res.responseText.replace(/<script(.|\s)*?\/script>/g, ""))
2461+
.append(res.responseText.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*< *\/ *script *>?/gi, ""))
24672462

24682463
// Locate the specified elements
24692464
.find(selector) :

src/ajax.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jQuery.fn.extend({
4848
jQuery("<div/>")
4949
// inject the contents of the document in, removing the scripts
5050
// to avoid any 'Permission Denied' errors in IE
51-
.append(res.responseText.replace(/<script(.|\s)*?\/script>/g, ""))
51+
.append(res.responseText.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*< *\/ *script *>?/gi, ""))
5252

5353
// Locate the specified elements
5454
.find(selector) :

version.txt

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

0 commit comments

Comments
 (0)