* @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(
* @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 = '';
# 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(
- '&' => '&',
- '"' => '"',
- "\n" => ' ',
- "\r" => ' ',
- "\t" => '	'
- ) ) . $quote;
+ if ( $wgHtml5 ) {
+ $ret .= " $key=$quote" . strtr( $value, array(
+ '&' => '&',
+ '"' => '"',
+ "\n" => ' ',
+ "\r" => ' ',
+ "\t" => '	'
+ ) ) . $quote;
+ } else {
+ $ret .= " $key=$quote" . Sanitizer::encodeAttribute( $value ) . $quote;
+ }
}
}
return $ret;