Partial revert of r56602: remove what is probably accidentally committed debugging...
[lhc/web/wiklou.git] / includes / Html.php
index bece509..8aa1de6 100644 (file)
@@ -195,6 +195,13 @@ class Html {
         * @return array An array of attributes functionally identical to $attribs
         */
        private static function dropDefaults( $element, $attribs ) {
+               # Don't bother doing anything if we aren't outputting HTML5; it's too
+               # much of a pain to maintain two sets of defaults.
+               global $wgHtml5;
+               if ( !$wgHtml5 ) {
+                       return $attribs;
+               }
+
                static $attribDefaults = array(
                        'area' => array( 'shape' => 'rect' ),
                        'button' => array(
@@ -286,7 +293,7 @@ class Html {
         * @return string HTML fragment that goes between element name and '>'
         *   (starting with a space if at least one attribute is output)
         */
-       public static function expandAttributes( $attribs ) {
+       public static function expandAttributes( $attribs = array() ) {
                global $wgHtml5, $wgWellFormedXml;
 
                $ret = '';
@@ -335,13 +342,17 @@ class Html {
                                # and we don't need <> escaped here, we may as well not call
                                # htmlspecialchars().  FIXME: verify that we actually need to
                                # escape \n\r\t here, and explain why, exactly.
-                               $ret .= " $key=$quote" . strtr( $value, array(
-                                       '&' => '&amp;',
-                                       '"' => '&quot;',
-                                       "\n" => '&#10;',
-                                       "\r" => '&#13;',
-                                       "\t" => '&#9;'
-                               ) ) . $quote;
+                               if ( $wgHtml5 ) {
+                                       $ret .= " $key=$quote" . strtr( $value, array(
+                                               '&' => '&amp;',
+                                               '"' => '&quot;',
+                                               "\n" => '&#10;',
+                                               "\r" => '&#13;',
+                                               "\t" => '&#9;'
+                                       ) ) . $quote;
+                               } else {
+                                       $ret .= " $key=$quote" . Sanitizer::encodeAttribute( $value ) . $quote;
+                               }
                        }
                }
                return $ret;