Skip to content

Commit

Permalink
Revert "Adjust jQuery('html') detection to only match when html start…
Browse files Browse the repository at this point in the history
…s with '<' (counting space characters). Fixes #11290"

This reverts commit 239fc86.

The consensus is that this would change behavior too abruptly. We will warn in 1.8 and do this in 1.9.
  • Loading branch information
timmywil committed Jun 21, 2012
1 parent bc9945a commit c20e031
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ var
trimRight = /\s+$/,

// A simple way to check for HTML strings
// If starts-with '<'
rhtmlString = /^\s*(<[\w\W]+>)[^>]*$/,
// Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
// Ignore html if within quotes "" '' or brackets/parens [] ()
rhtmlString = /^(?:[^#<\\]*(<[\w\W]+>)(?![^\[]*\])(?![^\(]*\))(?![^']*')(?![^"]*")[^>]*$)/,

// Match a standalone tag
rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
Expand Down
4 changes: 3 additions & 1 deletion test/unit/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ test("jQuery()", function() {
div = jQuery("<div/><hr/><code/><b/>"),
exec = false,
long = "",
expected = 24,
expected = 26,
attrObj = {
click: function() { ok( exec, "Click executed." ); },
text: "test",
Expand Down Expand Up @@ -132,12 +132,14 @@ test("jQuery()", function() {
elem.remove();

equal( jQuery(" <div/> ").length, 1, "Make sure whitespace is trimmed." );
equal( jQuery(" a<div/>b ").length, 1, "Make sure whitespace and other characters are trimmed." );

for ( i = 0; i < 128; i++ ) {
long += "12345678";
}

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

test("selector state", function() {
Expand Down

0 comments on commit c20e031

Please sign in to comment.