Skip to content

Commit eb69988

Browse files
committed
🔒️ fix CVE-2012-6708
1 parent af543e2 commit eb69988

File tree

3 files changed

+3
-7
lines changed

3 files changed

+3
-7
lines changed

build/jslint-check.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
var JSLINT = require("./lib/jslint").JSLINT,
2-
print = require("sys").print,
2+
print = console.log,
33
src = require("fs").readFileSync("dist/jquery.js", "utf8");
44

55
JSLINT(src, { evil: true, forin: true, maxerr: 100 });

src/core.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ var jQuery = function( selector, context ) {
1717

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

2223
// Check if a string has a non-whitespace character in it
2324
rnotwhite = /\S/,

test/unit/core.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,11 @@ test("jQuery()", function() {
9797
// manually clean up detached elements
9898
elem.remove();
9999

100-
equals( jQuery(" <div/> ").length, 1, "Make sure whitespace is trimmed." );
101-
equals( jQuery(" a<div/>b ").length, 1, "Make sure whitespace and other characters are trimmed." );
102-
103100
var long = "";
104101
for ( var i = 0; i < 128; i++ ) {
105102
long += "12345678";
106103
}
107104

108-
equals( jQuery(" <div>" + long + "</div> ").length, 1, "Make sure whitespace is trimmed on long strings." );
109-
equals( jQuery(" a<div>" + long + "</div>b ").length, 1, "Make sure whitespace and other characters are trimmed on long strings." );
110105
});
111106

112107
test("selector state", function() {

0 commit comments

Comments
 (0)