* HTML sanitizer: correct multiple attributes by keeping last, not first
authorBrion Vibber <brion@users.mediawiki.org>
Wed, 29 Jun 2005 21:50:11 +0000 (21:50 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Wed, 29 Jun 2005 21:50:11 +0000 (21:50 +0000)
This corrects a regression reported with some fancy templated tables at
http://en.wikipedia.org/wiki/Wikipedia:WikiProject_Chemicals/Organization

RELEASE-NOTES
includes/Sanitizer.php
maintenance/parserTests.txt

index 4e18b7e..fb594b3 100644 (file)
@@ -422,6 +422,7 @@ Various bugfixes, small features, and a few experimental things:
 * Copy IRC-over-UDP update option from REL1_4
 * (bug 2548) Keep summary on 'show changes' of section edit
 * Move center on toc to title part to avoid breaking .toc style usage
+* HTML sanitizer: correct multiple attributes by keeping last, not first
 
 
 === Caveats ===
index 2170a34..dd59f44 100644 (file)
@@ -574,9 +574,9 @@ class Sanitizer {
                                '/(' . URL_PROTOCOLS . '):/',
                                '\\1&#58;', $value );
                        
-                       if( !isset( $attribs[$attribute] ) ) {
-                               $attribs[$attribute] = "$attribute=\"$value\"";
-                       }
+                       // If this attribute was previously set, override it.
+                       // Output should only have one attribute of each name.
+                       $attribs[$attribute] = "$attribute=\"$value\"";
                }
                if( empty( $attribs ) ) {
                        return '';
index dbb2b71..d379301 100644 (file)
@@ -2214,7 +2214,31 @@ div with illegal double attributes
 !! input
 <div align="center" align="right">HTML rocks</div>
 !! result
-<div align="center">HTML rocks</div>
+<div align="right">HTML rocks</div>
+
+!!end
+
+!! test
+HTML multiple attributes correction
+!! input
+<p class="error" class="awesome">Awesome!</p>
+!! result
+<p class="awesome">Awesome!</p>
+
+!!end
+
+!! test
+Table multiple attributes correction
+!! input
+{|
+!+ class="error" class="awesome"| status
+|}
+!! result
+<table>
+<tr>
+<th class="awesome">status</th>
+</tr>
+</table>
 
 !!end