Fix #13223. Re-allow leading space in HTML. Close gh-1264.

This commit is contained in:
Dave Methvin 2013-05-08 21:07:41 -04:00
parent 0135a223f4
commit 00eafdf028
3 changed files with 8 additions and 14 deletions

View File

@ -55,7 +55,7 @@ var
// 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) // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
// Strict HTML recognition (#11290: must start with <) // Strict HTML recognition (#11290: must start with <)
rquickExpr = /^(?:(<[\w\W]+>)[^>]*|#([\w-]*))$/, rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
// Match a standalone tag // Match a standalone tag
rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/, rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/,

View File

@ -33,7 +33,7 @@ test("jQuery()", function() {
div = jQuery("<div/><hr/><code/><b/>"), div = jQuery("<div/><hr/><code/><b/>"),
exec = false, exec = false,
lng = "", lng = "",
expected = 20, expected = 22,
attrObj = { attrObj = {
"text": "test", "text": "test",
"class": "test2", "class": "test2",
@ -108,6 +108,12 @@ test("jQuery()", function() {
equal( jQuery(document.body).get(0), jQuery("body").get(0), "Test passing an html node to the factory" ); equal( jQuery(document.body).get(0), jQuery("body").get(0), "Test passing an html node to the factory" );
elem = jQuery(" <em>hello</em>")[0];
equal( elem.nodeName.toLowerCase(), "em", "leading space" );
elem = jQuery("\n\n<em>world</em>")[0];
equal( elem.nodeName.toLowerCase(), "em", "leading newlines" );
elem = jQuery("<div/>", attrObj ); elem = jQuery("<div/>", attrObj );
if ( jQuery.fn.width ) { if ( jQuery.fn.width ) {

View File

@ -73,18 +73,6 @@ test("disconnected nodes - jQuery only", function() {
equal( $opt.is(":selected"), true, "selected option" ); equal( $opt.is(":selected"), true, "selected option" );
}); });
test("jQuery only - broken", 1, function() {
raises(function() {
// Setting context to null here somehow avoids QUnit's window.error handling
// making the e & e.message correct
// For whatever reason, without this,
// Sizzle.error will be called but no error will be seen in oldIE
jQuery.call( null, " <div/> " );
}, function( e ) {
return (/syntax.err/i).test( e.message );
}, "leading space invalid: $(' <div/> ')" );
});
testIframe("selector/html5_selector", "attributes - jQuery.attr", function( jQuery, window, document ) { testIframe("selector/html5_selector", "attributes - jQuery.attr", function( jQuery, window, document ) {
expect( 35 ); expect( 35 );