Use Sanitizer::encodeAttribute instead of raw htmlspecialchars for encoding attribute...
authorBrion Vibber <brion@users.mediawiki.org>
Fri, 7 Jul 2006 04:45:19 +0000 (04:45 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Fri, 7 Jul 2006 04:45:19 +0000 (04:45 +0000)
* Preserves tabs and newlines as given (they would otherwise be normalized to spaces by the XML input processor)
* When generating output back to wiki text, this avoids line-based block parsing breakage. (bug 6577)

includes/Xml.php
maintenance/parserTests.txt

index 6e2518f..5299336 100644 (file)
@@ -20,7 +20,7 @@ class Xml {
                $out = '<' . $element;\r
                if( !is_null( $attribs ) ) {\r
                        foreach( $attribs as $name => $val ) {\r
-                               $out .= ' ' . $name . '="' . htmlspecialchars( $val ) . '"';\r
+                               $out .= ' ' . $name . '="' . Sanitizer::encodeAttribute( $val ) . '"';\r
                        }\r
                }\r
                if( is_null( $contents ) ) {\r
index 920f478..0238051 100644 (file)
@@ -4448,6 +4448,15 @@ Fuzz testing: image with bogus manual thumbnail
 
 !!end
 
+!! test
+Fuzz testing: encoded newline in generated HTML replacements (bug 6577)
+!! input
+<pre dir="&#10;"></pre>
+!! result
+<pre dir="&#10;"></pre>
+
+!! end
+
 !! test
 Parsing optional HTML elements (Bug 6171)
 !! options