From aee072efe2f6c93a039697fc5340d64d0c0f36b7 Mon Sep 17 00:00:00 2001 From: Arlo Breault Date: Tue, 7 Jul 2015 09:47:35 -0700 Subject: [PATCH] Empty attribute syntax * The value is implicitly the empty string. http://www.w3.org/TR/html5/syntax.html#syntax-attribute-name Bug: T54330 Change-Id: I8591ef209fb7337fb39ad6e45135942d074373bc --- includes/Sanitizer.php | 7 ++++--- tests/parser/parserTests.txt | 24 +++++++++++++++--------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/includes/Sanitizer.php b/includes/Sanitizer.php index 2340cd9449..8422d9a793 100644 --- a/includes/Sanitizer.php +++ b/includes/Sanitizer.php @@ -1276,9 +1276,10 @@ class Sanitizer { # Double-quoted return $set[3]; } elseif ( !isset( $set[2] ) ) { - # In XHTML, attributes must have a value. - # For 'reduced' form, return explicitly the attribute name here. - return $set[1]; + # In XHTML, attributes must have a value so return an empty string. + # See "Empty attribute syntax", + # http://www.w3.org/TR/html5/syntax.html#syntax-attribute-name + return ""; } else { throw new MWException( "Tag conditions not met. This should never happen and is a bug." ); } diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index 18d9aa85e0..70c8c0c979 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -7980,8 +7980,8 @@ Handling html with a br self-closing tag

!! html/php -


-
+


+



@@ -14628,13 +14628,19 @@ Attribute test: unquoted but illegal value (hash)

!! end +# Parsoid does not serialize to empty attribute syntax, +# so wt2wt and html2wt cases are skipped !! test -Attribute test: no value +Attribute test: no value (T54330) +!! options +parsoid=wt2html,html2html !! wikitext foo -!! html -

foo +!! html/php +

foo

+!! html/parsoid +

foo

!! end !! test @@ -15165,7 +15171,7 @@ array ( 'width' => '200', 'height' => '100', 'depth' => '50', - 'square' => 'square', + 'square' => '', ) @@ -15213,7 +15219,7 @@ array ( 'width' => '200', 'height' => '100', 'depth' => '50', - 'square' => 'square', + 'square' => '', )

other stuff @@ -15360,7 +15366,7 @@ Sanitizer: Validating that and work, but only for Microdata !! html -

+

<meta http-equiv="refresh" content="5"> @@ -19279,7 +19285,7 @@ Page status indicators: Weird syntaxes that are okay showindicators !! wikitext - + !! html empty= name= -- 2.20.1