Empty attribute syntax
authorArlo Breault <abreault@wikimedia.org>
Tue, 7 Jul 2015 16:47:35 +0000 (09:47 -0700)
committerArlo Breault <abreault@wikimedia.org>
Tue, 7 Jul 2015 20:55:53 +0000 (13:55 -0700)
 * 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
tests/parser/parserTests.txt

index 2340cd9..8422d9a 100644 (file)
@@ -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." );
                }
index 18d9aa8..70c8c0c 100644 (file)
@@ -7980,8 +7980,8 @@ Handling html with a br self-closing tag
 <br title=bar/>
 <br title=bar/ >
 !! html/php
-<p><br title="title" />
-<br title="title" />
+<p><br title="" />
+<br title="" />
 <br />
 <br title="bar" />
 <br title="bar" />
@@ -14628,13 +14628,19 @@ Attribute test: unquoted but illegal value (hash)
 </p>
 !! 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
 <font color>foo</font>
-!! html
-<p><font color="color">foo</font>
+!! html/php
+<p><font color="">foo</font>
 </p>
+!! html/parsoid
+<p><font color="">foo</font></p>
 !! end
 
 !! test
@@ -15165,7 +15171,7 @@ array (
   'width' => '200',
   'height' => '100',
   'depth' => '50',
-  'square' => 'square',
+  'square' => '',
 )
 </pre>
 
@@ -15213,7 +15219,7 @@ array (
   'width' => '200',
   'height' => '100',
   'depth' => '50',
-  'square' => 'square',
+  'square' => '',
 )
 </pre>
 <p>other stuff
@@ -15360,7 +15366,7 @@ Sanitizer: Validating that <meta> and <link> work, but only for Microdata
        <link rel="stylesheet" itemprop="hello" href="{{SERVER}}">
 </div>
 !! html
-<div itemscope="itemscope">
+<div itemscope="">
 <p>    <meta itemprop="hello" content="world" />
        &lt;meta http-equiv="refresh" content="5"&gt;
        <meta itemprop="hello" content="5" />
@@ -19279,7 +19285,7 @@ Page status indicators: Weird syntaxes that are okay
 showindicators
 !! wikitext
 <indicator name="empty" />
-<indicator name></indicator>
+<indicator name="name"></indicator>
 !! html
 empty=
 name=