From 08aa4418c30cfc18ccc69a0f0f9cb9e17be6c196 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Mon, 12 Aug 2013 09:28:15 +0200 Subject: Update to MediaWiki 1.21.1 --- includes/Html.php | 230 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 126 insertions(+), 104 deletions(-) (limited to 'includes/Html.php') diff --git a/includes/Html.php b/includes/Html.php index b33d6fbb..af4b4bbf 100644 --- a/includes/Html.php +++ b/includes/Html.php @@ -48,7 +48,7 @@ * @since 1.16 */ class Html { - # List of void elements from HTML5, section 8.1.2 as of 2011-08-12 + // List of void elements from HTML5, section 8.1.2 as of 2011-08-12 private static $voidElements = array( 'area', 'base', @@ -68,8 +68,8 @@ class Html { 'wbr', ); - # Boolean attributes, which may have the value omitted entirely. Manually - # collected from the HTML5 spec as of 2011-08-12. + // Boolean attributes, which may have the value omitted entirely. Manually + // collected from the HTML5 spec as of 2011-08-12. private static $boolAttribs = array( 'async', 'autofocus', @@ -97,7 +97,7 @@ class Html { 'selected', 'truespeed', 'typemustmatch', - # HTML5 Microdata + // HTML5 Microdata 'itemscope', ); @@ -126,11 +126,11 @@ class Html { * content model. If $wgWellFormedXml is false, then a few bytes will be * shaved off the HTML output as well. * - * @param $element string The element's name, e.g., 'a' - * @param $attribs array Associative array of attributes, e.g., array( + * @param string $element The element's name, e.g., 'a' + * @param array $attribs Associative array of attributes, e.g., array( * 'href' => 'http://www.mediawiki.org/' ). See expandAttributes() for * further documentation. - * @param $contents string The raw HTML contents of the element: *not* + * @param string $contents The raw HTML contents of the element: *not* * escaped! * @return string Raw HTML */ @@ -139,7 +139,7 @@ class Html { $start = self::openElement( $element, $attribs ); if ( in_array( $element, self::$voidElements ) ) { if ( $wgWellFormedXml ) { - # Silly XML. + // Silly XML. return substr( $start, 0, -1 ) . ' />'; } return $start; @@ -160,8 +160,8 @@ class Html { */ public static function element( $element, $attribs = array(), $contents = '' ) { return self::rawElement( $element, $attribs, strtr( $contents, array( - # There's no point in escaping quotes, >, etc. in the contents of - # elements. + // There's no point in escaping quotes, >, etc. in the contents of + // elements. '&' => '&', '<' => '<' ) ) ); @@ -179,24 +179,20 @@ class Html { public static function openElement( $element, $attribs = array() ) { global $wgHtml5, $wgWellFormedXml; $attribs = (array)$attribs; - # This is not required in HTML5, but let's do it anyway, for - # consistency and better compression. + // This is not required in HTML5, but let's do it anyway, for + // consistency and better compression. $element = strtolower( $element ); - # In text/html, initial and tags can be omitted under - # pretty much any sane circumstances, if they have no attributes. See: - # + // In text/html, initial and tags can be omitted under + // pretty much any sane circumstances, if they have no attributes. See: + // if ( !$wgWellFormedXml && !$attribs && in_array( $element, array( 'html', 'head' ) ) ) { return ''; } - # Remove HTML5-only attributes if we aren't doing HTML5, and disable - # form validation regardless (see bug 23769 and the more detailed - # comment in expandAttributes()) + // Remove invalid input types if ( $element == 'input' ) { - # Whitelist of types that don't cause validation. All except - # 'search' are valid in XHTML1. $validTypes = array( 'hidden', 'text', @@ -208,9 +204,9 @@ class Html { 'image', 'reset', 'button', - 'search', ); + // Allow more input types in HTML5 mode if( $wgHtml5 ) { $validTypes = array_merge( $validTypes, array( 'datetime', @@ -232,17 +228,19 @@ class Html { && !in_array( $attribs['type'], $validTypes ) ) { unset( $attribs['type'] ); } - - if ( isset( $attribs['type'] ) && $attribs['type'] == 'search' - && !$wgHtml5 ) { - unset( $attribs['type'] ); - } } if ( !$wgHtml5 && $element == 'textarea' && isset( $attribs['maxlength'] ) ) { unset( $attribs['maxlength'] ); } + // According to standard the default type for