Arlolra has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/229453

Change subject: More empty attribute syntax
......................................................................

More empty attribute syntax

 * This is a follow up to I8591ef209fb7337fb39ad6e45135942d074373bc

 * Brings us closer to the html5 attribute parsing algorithm described
   in 
http://www.w3.org/TR/html5/syntax.html#concept-get-attributes-when-sniffing

 * However, there are some inconsistencies (besides the charset). If
   I'm reading it right, the spec says <div class=  style="123">hi</div>
   should parse as <div class=" " style="123">hi</div> but Parsoid will
   yield <div class="" style="123">hi</div> and Chrome gives
   <div class="style=\"123\"">hi</div>. This seems to be an edge case
   when the first character is a space. Otherwise, we all agree.

Change-Id: Ic2fc1b573a55a847e6c05707678b58c1189ecc52
---
M includes/Sanitizer.php
M tests/parser/parserTests.txt
2 files changed, 10 insertions(+), 19 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/53/229453/1

diff --git a/includes/Sanitizer.php b/includes/Sanitizer.php
index cd936f3..f28eab5 100644
--- a/includes/Sanitizer.php
+++ b/includes/Sanitizer.php
@@ -348,7 +348,7 @@
                                         # The attribute value: quoted or alone
                                          \"([^<\"]*)\"
                                         | '([^<']*)'
-                                        |  
([a-zA-Z0-9!#$%&()*,\\-.\\/:;<>?@[\\]^_`{|}~]+)
+                                        |  
([a-zA-Z0-9!#$%&()*,\\-.\\/:;<>?@[\\]^_`{|}~]*)
                                        )
                                )?(?=$space|\$)/sx";
                }
diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt
index b9ff013..5a50162 100644
--- a/tests/parser/parserTests.txt
+++ b/tests/parser/parserTests.txt
@@ -14872,12 +14872,8 @@
 
 !!end
 
-# FIXME: produce empty string instead of "class" in the PHP parser, following
-# the HTML5 spec.
 !! test
 div with empty attribute value, space before equals
-!! options
-parsoid
 !! wikitext
 <div class =>HTML rocks</div>
 !! html
@@ -14887,8 +14883,6 @@
 
 !! test
 div with multiple empty attribute values
-!! options
-parsoid
 !! wikitext
 <div id= title=>HTML rocks</div>
 !! html
@@ -14898,13 +14892,17 @@
 
 !! test
 table with multiple empty attribute values
-!! options
-parsoid
 !! wikitext
 {| title= id=
 | hi
 |}
-!! html
+!! html/php
+<table title="" id="">
+<tr>
+<td> hi
+</td></tr></table>
+
+!! html/parsoid
 <table title="" id="">
 <tbody><tr><td> hi</td></tr>
 </tbody></table>
@@ -14921,13 +14919,6 @@
 <div title="{}">Foo</div>
 !! end
 
-# This it very inconsistent in the PHP parser: it returns 
-# class="class" if there is a space between the name and the equal sign (see
-# 'div with empty attribute value, space before equals'), but strips the
-# attribute completely if the space is missing. We hope that not much content
-# depends on this, so are implementing the behavior below in Parsoid for
-# consistencies' sake.
-# FIXME: fix this behavior in the PHP parser?
 !! test
 div with empty attribute value, no space before equals
 !! options
@@ -14935,7 +14926,7 @@
 !! wikitext
 <div class=>HTML rocks</div>
 !! html/php
-<div>HTML rocks</div>
+<div class="">HTML rocks</div>
 
 !! html/parsoid
 <div class="">HTML rocks</div>
@@ -15259,7 +15250,7 @@
 !! wikitext
 <font color=>foo</font>
 !! html
-<p><font>foo</font>
+<p><font color="">foo</font>
 </p>
 !! end
 

-- 
To view, visit https://gerrit.wikimedia.org/r/229453
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic2fc1b573a55a847e6c05707678b58c1189ecc52
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Arlolra <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to