Commit 239fc86b authored by timmywil's avatar timmywil

Adjust jQuery('html') detection to only match when html starts with '<'...

Adjust jQuery('html') detection to only match when html starts with '<' (counting space characters). Fixes #11290
parent 286c4d91
...@@ -40,9 +40,8 @@ var ...@@ -40,9 +40,8 @@ var
trimRight = /\s+$/, trimRight = /\s+$/,
// A simple way to check for HTML strings // A simple way to check for HTML strings
// Prioritize #id over <tag> to avoid XSS via location.hash (#9521) // If starts-with '<'
// Ignore html if within quotes "" '' or brackets/parens [] () rhtmlString = /^\s*(<[\w\W]+>)[^>]*$/,
rhtmlString = /^(?:[^#<\\]*(<[\w\W]+>)(?![^\[]*\])(?![^\(]*\))(?![^']*')(?![^"]*")[^>]*$)/,
// Match a standalone tag // Match a standalone tag
rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/, rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
......
...@@ -27,7 +27,7 @@ test("jQuery()", function() { ...@@ -27,7 +27,7 @@ test("jQuery()", function() {
div = jQuery("<div/><hr/><code/><b/>"), div = jQuery("<div/><hr/><code/><b/>"),
exec = false, exec = false,
long = "", long = "",
expected = 26, expected = 24,
attrObj = { attrObj = {
click: function() { ok( exec, "Click executed." ); }, click: function() { ok( exec, "Click executed." ); },
text: "test", text: "test",
...@@ -132,14 +132,12 @@ test("jQuery()", function() { ...@@ -132,14 +132,12 @@ test("jQuery()", function() {
elem.remove(); elem.remove();
equal( jQuery(" <div/> ").length, 1, "Make sure whitespace is trimmed." ); 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++ ) { for ( i = 0; i < 128; i++ ) {
long += "12345678"; long += "12345678";
} }
equal( jQuery(" <div>" + long + "</div> ").length, 1, "Make sure whitespace is trimmed on long strings." ); 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() { test("selector state", function() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment