Daniel Friesen has uploaded a new change for review. https://gerrit.wikimedia.org/r/63106
Change subject: Drop support for XHTML 1.1 ...................................................................... Drop support for XHTML 1.1 * $wgHtml5 = false; is now ignored completely. * $wgDocType and $wgDTD have been removed. * $wgXhtmlDefaultNamespace is now ignored. * XHTML5 will be output if $wgMimeType is set to an XML mime type (according to HTML5's rules). * For backwards compatibility with extensions $wgHtml5 and $wgXhtmlDefaultNamespace are set in Setup.php but depending on them is deprecated. Change-Id: Iad9634e2ee420b5a3bbffe550421fde4fa1819b0 --- M RELEASE-NOTES-1.22 M includes/DefaultSettings.php M includes/Html.php M includes/OutputPage.php M includes/Sanitizer.php M includes/Setup.php M includes/SkinTemplate.php M includes/parser/Parser.php M tests/phpunit/includes/HtmlTest.php M tests/phpunit/includes/SanitizerTest.php M tests/phpunit/includes/XmlSelectTest.php M tests/phpunit/includes/XmlTest.php M tests/phpunit/includes/parser/NewParserTest.php 13 files changed, 145 insertions(+), 211 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/06/63106/1 diff --git a/RELEASE-NOTES-1.22 b/RELEASE-NOTES-1.22 index 50444a7..db460bf 100644 --- a/RELEASE-NOTES-1.22 +++ b/RELEASE-NOTES-1.22 @@ -15,6 +15,11 @@ activated; when $wgUseVFormCreateAccount is true, the redesign of Special:UserLogin/signup is activated. * $wgVectorUseIconWatch is now enabled by default. +* $wgDocType and $wgDTD have been removed and are no longer used for the DOCTYPE. +* $wgHtml5 is no longer used by core. Setting it to false will no longer disable HTML5. + It is still set to true for extension compatibility but doing so in extensions is deprecated. +* $wgXhtmlDefaultNamespace is no longer used by core. Setting it will no longer change the + xmlns used by MediaWiki. Reliance on this variable by extensions is deprecated. === New features in 1.22 === * (bug 44525) mediawiki.jqueryMsg can now parse (whitelisted) HTML elements and attributes. @@ -67,6 +72,8 @@ * mediawiki.log: Added log.warn wrapper (uses console.warn and console.trace). * mediawiki.log: Implemented log.deprecate. This method defines a property and uses ES5 getter/setter to emit a warning when they are used. +* XHTML5 support has been improved. If you set $wgMimeType = 'application/xhtml+xml' + MediaWiki will try outputting markup acording to XHTML5 rules. === Bug fixes in 1.22 === * Disable Special:PasswordReset when $wgEnableEmail. Previously one could still @@ -147,6 +154,7 @@ user ID, or file name. The old Special:Filepath page was reimplemented to redirect through Special:Redirect. * Monobook: Removed the old conditional stylesheets for Opera 6, 7 and 9. +* Support for XHTML 1.1 has been removed. MediaWiki now only outputs (X)HTML5. == Compatibility == diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 407ac8f..b52bf14 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -2518,48 +2518,36 @@ $wgMimeType = 'text/html'; /** - * The content type used in script tags. This is mostly going to be ignored if - * $wgHtml5 is true, at least for actual HTML output, since HTML5 doesn't - * require a MIME type for JavaScript or CSS (those are the default script and - * style languages). + * The content type used in script tags. This is mostly going to be ignored at + * least for actual HTML output, since HTML5 doesn't require a MIME type for + * JavaScript or CSS (those are the default script and style languages). */ $wgJsMimeType = 'text/javascript'; /** - * The HTML document type. Ignored if $wgHtml5 is true, since <!DOCTYPE html> - * doesn't actually have a doctype part to put this variable's contents in. + * The default xmlns attribute. The option to define this has been removed. + * The value of this variable is no longer used by core and is set to a fixed + * value in Setup.php for compatibility with extensions that depend on the value + * of this variable being set. Such a dependency however is deprecated. + * @deprecated */ -$wgDocType = '-//W3C//DTD XHTML 1.0 Transitional//EN'; +$wgXhtmlDefaultNamespace = null; /** - * The URL of the document type declaration. Ignored if $wgHtml5 is true, - * since HTML5 has no DTD, and <!DOCTYPE html> doesn't actually have a DTD part - * to put this variable's contents in. - */ -$wgDTD = 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'; - -/** - * The default xmlns attribute. Ignored if $wgHtml5 is true (or it's supposed - * to be), since we don't currently support XHTML5, and in HTML5 (i.e., served - * as text/html) the attribute has no effect, so why bother? - */ -$wgXhtmlDefaultNamespace = 'http://www.w3.org/1999/xhtml'; - -/** - * Should we output an HTML5 doctype? If false, use XHTML 1.0 Transitional - * instead, and disable HTML5 features. This may eventually be removed and set - * to always true. If it's true, a number of other settings will be irrelevant - * and have no effect. + * Previously used to determine if we should output an HTML5 doctype. + * This is no longer used as we always output HTML5 now. For compatibility with + * extensions that still check the value of this config it's value is now forced + * to true by Setup.php. + * @deprecated */ $wgHtml5 = true; /** * Defines the value of the version attribute in the <html> tag, if any. - * This is ignored if $wgHtml5 is false. If $wgAllowRdfaAttributes and - * $wgHtml5 are both true, and this evaluates to boolean false (like if it's - * left at the default null value), it will be auto-initialized to the correct - * value for RDFa+HTML5. As such, you should have no reason to ever actually - * set this to anything. + * If $wgAllowRdfaAttributes is true, and this evaluates to boolean false + * (like if it's left at the default null value), it will be auto-initialized + * to the correct value for RDFa+HTML5. As such, you should have no reason to + * ever actually set this to anything. */ $wgHtml5Version = null; @@ -2570,7 +2558,7 @@ $wgAllowRdfaAttributes = false; /** - * Enabled HTML5 microdata attributes for use in wikitext, if $wgHtml5 is also true. + * Enabled HTML5 microdata attributes for use in wikitext. */ $wgAllowMicrodataAttributes = false; @@ -2604,8 +2592,7 @@ * Normally we wouldn't have to define this in the root "<html>" * element, but IE needs it there in some circumstances. * - * This is ignored if $wgHtml5 is true, for the same reason as - * $wgXhtmlDefaultNamespace. + * This is ignored if $wgMimeType is set to a non-XML mimetype. */ $wgXhtmlNamespaces = array(); diff --git a/includes/Html.php b/includes/Html.php index cb082a1..917e70a 100644 --- a/includes/Html.php +++ b/includes/Html.php @@ -36,8 +36,8 @@ * * There are two important configuration options this class uses: * - * $wgHtml5: If this is set to false, then all output should be valid XHTML 1.0 - * Transitional. + * $wgMimeType: If this is set to an xml mimetype then output should be + * valid XHTML5. * $wgWellFormedXml: If this is set to true, then all output should be * well-formed XML (quotes on attributes, self-closing tags, etc.). * @@ -99,19 +99,6 @@ 'typemustmatch', // HTML5 Microdata 'itemscope', - ); - - private static $HTMLFiveOnlyAttribs = array( - 'autocomplete', - 'autofocus', - 'max', - 'min', - 'multiple', - 'pattern', - 'placeholder', - 'required', - 'step', - 'spellcheck', ); /** @@ -177,7 +164,7 @@ * @return string */ public static function openElement( $element, $attribs = array() ) { - global $wgHtml5, $wgWellFormedXml; + global $wgWellFormedXml; $attribs = (array)$attribs; // This is not required in HTML5, but let's do it anyway, for // consistency and better compression. @@ -204,34 +191,26 @@ 'image', 'reset', 'button', - ); - // Allow more input types in HTML5 mode - if ( $wgHtml5 ) { - $validTypes = array_merge( $validTypes, array( - 'datetime', - 'datetime-local', - 'date', - 'month', - 'time', - 'week', - 'number', - 'range', - 'email', - 'url', - 'search', - 'tel', - 'color', - ) ); - } + // HTML input types + 'datetime', + 'datetime-local', + 'date', + 'month', + 'time', + 'week', + 'number', + 'range', + 'email', + 'url', + 'search', + 'tel', + 'color', + ); if ( isset( $attribs['type'] ) && !in_array( $attribs['type'], $validTypes ) ) { unset( $attribs['type'] ); } - } - - if ( !$wgHtml5 && $element == 'textarea' && isset( $attribs['maxlength'] ) ) { - unset( $attribs['maxlength'] ); } // According to standard the default type for <button> elements is "submit". @@ -294,12 +273,6 @@ * @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; - } // Whenever altering this array, please provide a covering test case // in HtmlTest::provideElementsWithAttributesHavingDefaultValues @@ -444,7 +417,7 @@ * (starting with a space if at least one attribute is output) */ public static function expandAttributes( $attribs ) { - global $wgHtml5, $wgWellFormedXml; + global $wgWellFormedXml; $ret = ''; $attribs = (array)$attribs; @@ -460,14 +433,9 @@ $key = $value; } - // Not technically required in HTML5, but required in XHTML 1.0, - // and we'd like consistency and better compression anyway. + // Not technically required in HTML5 but we'd like consistency + // and better compression anyway. $key = strtolower( $key ); - - // Here we're blacklisting some HTML5-only attributes... - if ( !$wgHtml5 && in_array( $key, self::$HTMLFiveOnlyAttribs ) ) { - continue; - } // Bug 23769: Blacklist all form validation attributes for now. Current // (June 2010) WebKit has no UI, so the form just refuses to submit @@ -552,15 +520,12 @@ } if ( in_array( $key, self::$boolAttribs ) ) { - // In XHTML 1.0 Transitional, the value needs to be equal to the - // key. In HTML5, we can leave the value empty instead. If we - // don't need well-formed XML, we can omit the = entirely. + // In HTML5, we can leave the value empty. If we don't need + // well-formed XML, we can omit the = entirely. if ( !$wgWellFormedXml ) { $ret .= " $key"; - } elseif ( $wgHtml5 ) { - $ret .= " $key=\"\""; } else { - $ret .= " $key=\"$key\""; + $ret .= " $key=\"\""; } } else { // Apparently we need to entity-encode \n, \r, \t, although the @@ -602,13 +567,9 @@ * @return string Raw HTML */ public static function inlineScript( $contents ) { - global $wgHtml5, $wgJsMimeType, $wgWellFormedXml; + global $wgJsMimeType, $wgWellFormedXml; $attrs = array(); - - if ( !$wgHtml5 ) { - $attrs['type'] = $wgJsMimeType; - } if ( $wgWellFormedXml && preg_match( '/[<&]/', $contents ) ) { $contents = "/*<![CDATA[*/$contents/*]]>*/"; @@ -625,13 +586,9 @@ * @return string Raw HTML */ public static function linkedScript( $url ) { - global $wgHtml5, $wgJsMimeType; + global $wgJsMimeType; $attrs = array( 'src' => $url ); - - if ( !$wgHtml5 ) { - $attrs['type'] = $wgJsMimeType; - } return self::element( 'script', $attrs ); } @@ -677,8 +634,7 @@ /** * Convenience function to produce an "<input>" element. This supports the - * new HTML5 input types and attributes, and will silently strip them if - * $wgHtml5 is false. + * new HTML5 input types and attributes. * * @param $name string name attribute * @param $value mixed value attribute @@ -712,9 +668,7 @@ * Convenience function to produce an "<input>" element. * * This supports leaving out the cols= and rows= which Xml requires and are - * required by HTML4/XHTML but not required by HTML5 and will silently set - * cols="" and rows="" if $wgHtml5 is false and cols and rows are omitted - * (HTML4 validates present but empty cols="" and rows="" as valid). + * required by HTML4/XHTML but not required by HTML5. * * @param $name string name attribute * @param $value string value attribute @@ -723,19 +677,7 @@ * @return string Raw HTML */ public static function textarea( $name, $value = '', $attribs = array() ) { - global $wgHtml5; - $attribs['name'] = $name; - - if ( !$wgHtml5 ) { - if ( !isset( $attribs['cols'] ) ) { - $attribs['cols'] = ""; - } - - if ( !isset( $attribs['rows'] ) ) { - $attribs['rows'] = ""; - } - } if ( substr( $value, 0, 1 ) == "\n" ) { // Workaround for bug 12130: browsers eat the initial newline @@ -859,28 +801,29 @@ public static function htmlHeader( $attribs = array() ) { $ret = ''; - global $wgMimeType; + global $wgHtml5Version, $wgMimeType, $wgXhtmlNamespaces; - if ( self::isXmlMimeType( $wgMimeType ) ) { + $isXHTML = self::isXmlMimeType( $wgMimeType ); + + if ( $isXHTML ) { // XHTML5 + // XML mimetyped markup should have an xml header. + // However a DOCTYPE is not needed. $ret .= "<?xml version=\"1.0\" encoding=\"UTF-8\" ?" . ">\n"; - } - global $wgHtml5, $wgHtml5Version, $wgDocType, $wgDTD; - global $wgXhtmlNamespaces, $wgXhtmlDefaultNamespace; + // Add the standard xmlns + $attribs['xmlns'] = 'http://www.w3.org/1999/xhtml'; - if ( $wgHtml5 ) { - $ret .= "<!DOCTYPE html>\n"; - - if ( $wgHtml5Version ) { - $attribs['version'] = $wgHtml5Version; - } - } else { - $ret .= "<!DOCTYPE html PUBLIC \"$wgDocType\" \"$wgDTD\">\n"; - $attribs['xmlns'] = $wgXhtmlDefaultNamespace; - + // And support custom namespaces foreach ( $wgXhtmlNamespaces as $tag => $ns ) { $attribs["xmlns:$tag"] = $ns; } + } else { // HTML5 + // DOCTYPE + $ret .= "<!DOCTYPE html>\n"; + } + + if ( $wgHtml5Version ) { + $attribs['version'] = $wgHtml5Version; } $html = Html::openElement( 'html', $attribs ); @@ -901,14 +844,11 @@ * @return Boolean */ public static function isXmlMimeType( $mimetype ) { - switch ( $mimetype ) { - case 'text/xml': - case 'application/xhtml+xml': - case 'application/xml': - return true; - default: - return false; - } + # http://www.whatwg.org/specs/web-apps/current-work/multipage/infrastructure.html#xml-mime-type + # * text/xml + # * application/xml + # * Any mimetype with a subtype ending in +xml (this implicitly includes application/xhtml+xml) + return (bool) preg_match( '!^(text|application)/xml$|^.+/.+\+xml$!', $mimetype ); } /** diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 746cd0e..32aa67e 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -3134,7 +3134,7 @@ */ public function getHeadLinksArray( $addContentType = false ) { global $wgUniversalEditButton, $wgFavicon, $wgAppleTouchIcon, $wgEnableAPI, - $wgSitename, $wgVersion, $wgHtml5, $wgMimeType, + $wgSitename, $wgVersion, $wgMimeType, $wgFeed, $wgOverrideSiteFeed, $wgAdvertisedFeedTypes, $wgDisableLangConversion, $wgCanonicalLanguageLinks, $wgRightsPage, $wgRightsUrl; @@ -3144,20 +3144,9 @@ $canonicalUrl = $this->mCanonicalUrl; if ( $addContentType ) { - if ( $wgHtml5 ) { - # More succinct than <meta http-equiv=Content-Type>, has the - # same effect - $tags['meta-charset'] = Html::element( 'meta', array( 'charset' => 'UTF-8' ) ); - } else { - $tags['meta-content-type'] = Html::element( 'meta', array( - 'http-equiv' => 'Content-Type', - 'content' => "$wgMimeType; charset=UTF-8" - ) ); - $tags['meta-content-style-type'] = Html::element( 'meta', array( // bug 15835 - 'http-equiv' => 'Content-Style-Type', - 'content' => 'text/css' - ) ); - } + # More succinct than <meta http-equiv=Content-Type>, has the + # same effect + $tags['meta-charset'] = Html::element( 'meta', array( 'charset' => 'UTF-8' ) ); } $tags['meta-generator'] = Html::element( 'meta', array( diff --git a/includes/Sanitizer.php b/includes/Sanitizer.php index e757021..cc7a9d2 100644 --- a/includes/Sanitizer.php +++ b/includes/Sanitizer.php @@ -1,6 +1,6 @@ <?php /** - * XHTML sanitizer for %MediaWiki. + * HTML sanitizer for %MediaWiki. * * Copyright © 2002-2005 Brion Vibber <[email protected]> et al * http://www.mediawiki.org/ @@ -25,7 +25,7 @@ */ /** - * XHTML sanitizer for MediaWiki + * HTML sanitizer for MediaWiki * @ingroup Parser */ class Sanitizer { @@ -364,7 +364,7 @@ * @return string */ static function removeHTMLtags( $text, $processCallback = null, $args = array(), $extratags = array(), $removetags = array() ) { - global $wgUseTidy, $wgHtml5, $wgAllowMicrodataAttributes, $wgAllowImageTag; + global $wgUseTidy, $wgAllowMicrodataAttributes, $wgAllowImageTag; static $htmlpairsStatic, $htmlsingle, $htmlsingleonly, $htmlnest, $tabletags, $htmllist, $listtags, $htmlsingleallowed, $htmlelementsStatic, $staticInitialised; @@ -373,7 +373,7 @@ // Base our staticInitialised variable off of the global config state so that if the globals // are changed (like in the screwed up test system) we will re-initialise the settings. - $globalContext = implode( '-', compact( 'wgHtml5', 'wgAllowMicrodataAttributes', 'wgAllowImageTag' ) ); + $globalContext = implode( '-', compact( 'wgAllowMicrodataAttributes', 'wgAllowImageTag' ) ); if ( !$staticInitialised || $staticInitialised != $globalContext ) { $htmlpairsStatic = array( # Tags that must be closed @@ -382,18 +382,15 @@ 'strike', 'strong', 'tt', 'var', 'div', 'center', 'blockquote', 'ol', 'ul', 'dl', 'table', 'caption', 'pre', 'ruby', 'rt', 'rb', 'rp', 'p', 'span', 'abbr', 'dfn', - 'kbd', 'samp' + 'kbd', 'samp', 'data', 'time', 'mark' ); - if ( $wgHtml5 ) { - $htmlpairsStatic = array_merge( $htmlpairsStatic, array( 'data', 'time', 'mark' ) ); - } $htmlsingle = array( 'br', 'hr', 'li', 'dt', 'dd' ); $htmlsingleonly = array( # Elements that cannot have close tags 'br', 'hr' ); - if ( $wgHtml5 && $wgAllowMicrodataAttributes ) { + if ( $wgAllowMicrodataAttributes ) { $htmlsingle[] = $htmlsingleonly[] = 'meta'; $htmlsingle[] = $htmlsingleonly[] = 'link'; } @@ -709,7 +706,7 @@ * @todo Check for unique id attribute :P */ static function validateAttributes( $attribs, $whitelist ) { - global $wgAllowRdfaAttributes, $wgAllowMicrodataAttributes, $wgHtml5; + global $wgAllowRdfaAttributes, $wgAllowMicrodataAttributes; $whitelist = array_flip( $whitelist ); $hrefExp = '/^(' . wfUrlProtocols() . ')[^\s]+$/'; @@ -725,8 +722,8 @@ continue; } - # Allow any attribute beginning with "data-", if in HTML5 mode - if ( !( $wgHtml5 && preg_match( '/^data-/i', $attribute ) ) && !isset( $whitelist[$attribute] ) ) { + # Allow any attribute beginning with "data-" + if ( !(preg_match( '/^data-/i', $attribute ) ) && !isset( $whitelist[$attribute] ) ) { continue; } @@ -1029,10 +1026,10 @@ * @return String */ static function escapeId( $id, $options = array() ) { - global $wgHtml5, $wgExperimentalHtmlIds; + global $wgExperimentalHtmlIds; $options = (array)$options; - if ( $wgHtml5 && $wgExperimentalHtmlIds && !in_array( 'legacy', $options ) ) { + if ( $wgExperimentalHtmlIds && !in_array( 'legacy', $options ) ) { $id = Sanitizer::decodeCharReferences( $id ); $id = preg_replace( '/[ \t\n\r\f_\'"&#%]+/', '_', $id ); $id = trim( $id, '_' ); @@ -1422,10 +1419,10 @@ * @return Array */ static function setupAttributeWhitelist() { - global $wgAllowRdfaAttributes, $wgHtml5, $wgAllowMicrodataAttributes; + global $wgAllowRdfaAttributes, $wgAllowMicrodataAttributes; static $whitelist, $staticInitialised; - $globalContext = implode( '-', compact( 'wgAllowRdfaAttributes', 'wgHtml5', 'wgAllowMicrodataAttributes' ) ); + $globalContext = implode( '-', compact( 'wgAllowRdfaAttributes', 'wgAllowMicrodataAttributes' ) ); if ( isset( $whitelist ) && $staticInitialised == $globalContext ) { return $whitelist; @@ -1451,7 +1448,7 @@ ) ); } - if ( $wgHtml5 && $wgAllowMicrodataAttributes ) { + if ( $wgAllowMicrodataAttributes ) { # add HTML5 microdata tags as specified by http://www.whatwg.org/specs/web-apps/current-work/multipage/microdata.html#the-microdata-model $common = array_merge( $common, array( 'itemid', 'itemprop', 'itemref', 'itemscope', 'itemtype' @@ -1590,8 +1587,8 @@ # 15.3 'hr' => array_merge( $common, array( 'noshade', 'size', 'width' ) ), - # XHTML Ruby annotation text module, simple ruby only. - # http://www.w3c.org/TR/ruby/ + # HTML Ruby annotation text module, simple ruby only. + # http://www.whatwg.org/specs/web-apps/current-work/multipage/text-level-semantics.html#the-ruby-element 'ruby' => $common, # rbc # rtc @@ -1607,25 +1604,20 @@ # HTML 5 section 4.6 'bdi' => $common, - ); - - if ( $wgHtml5 ) { # HTML5 elements, defined by: # http://www.whatwg.org/specs/web-apps/current-work/multipage/ - $whitelist += array( - 'data' => array_merge( $common, array( 'value' ) ), - 'time' => array_merge( $common, array( 'datetime' ) ), - 'mark' => $common, + 'data' => array_merge( $common, array( 'value' ) ), + 'time' => array_merge( $common, array( 'datetime' ) ), + 'mark' => $common, - // meta and link are only permitted by removeHTMLtags when Microdata - // is enabled so we don't bother adding a conditional to hide these - // Also meta and link are only valid in WikiText as Microdata elements - // (ie: validateTag rejects tags missing the attributes needed for Microdata) - // So we don't bother including $common attributes that have no purpose. - 'meta' => array( 'itemprop', 'content' ), - 'link' => array( 'itemprop', 'href' ), - ); - } + // meta and link are only permitted by removeHTMLtags when Microdata + // is enabled so we don't bother adding a conditional to hide these + // Also meta and link are only valid in WikiText as Microdata elements + // (ie: validateTag rejects tags missing the attributes needed for Microdata) + // So we don't bother including $common attributes that have no purpose. + 'meta' => array( 'itemprop', 'content' ), + 'link' => array( 'itemprop', 'href' ), + ); $staticInitialised = $globalContext; diff --git a/includes/Setup.php b/includes/Setup.php index 565ca49..b4f0ed1 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -344,7 +344,14 @@ $wgActions[$action] = false; } -if ( !$wgHtml5Version && $wgHtml5 && $wgAllowRdfaAttributes ) { +# We always output html5, override any change made by local settings +$wgHtml5 = true; + +# Setting wgXhtmlDefaultNamespace is no longer supported. +# However define it here for extensions that depend on it's value. +$wgXhtmlDefaultNamespace = 'http://www.w3.org/1999/xhtml'; + +if ( !$wgHtml5Version && $wgAllowRdfaAttributes ) { # see http://www.w3.org/TR/rdfa-in-html/#document-conformance if ( $wgMimeType == 'application/xhtml+xml' ) { $wgHtml5Version = 'XHTML+RDFa 1.0'; diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index e53d424..07f5ec0 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -174,7 +174,7 @@ global $wgContLang; global $wgScript, $wgStylePath; global $wgMimeType, $wgJsMimeType; - global $wgXhtmlDefaultNamespace, $wgXhtmlNamespaces, $wgHtml5Version; + global $wgXhtmlNamespaces, $wgHtml5Version; global $wgDisableCounters, $wgSitename, $wgLogo; global $wgMaxCredits, $wgShowCreditsIfMax; global $wgPageShowWatchingUsers; @@ -236,7 +236,7 @@ $tpl->set( 'jsvarurl', false ); - $tpl->setRef( 'xhtmldefaultnamespace', $wgXhtmlDefaultNamespace ); + $tpl->setRef( 'xhtmldefaultnamespace', 'http://www.w3.org/1999/xhtml' ); $tpl->set( 'xhtmlnamespaces', $wgXhtmlNamespaces ); $tpl->set( 'html5version', $wgHtml5Version ); $tpl->set( 'headlinks', $out->getHeadLinks() ); diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index b2bcd61..455d748 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -4131,7 +4131,7 @@ * @private */ function formatHeadings( $text, $origText, $isMain = true ) { - global $wgMaxTocLevel, $wgHtml5, $wgExperimentalHtmlIds; + global $wgMaxTocLevel, $wgExperimentalHtmlIds; # Inhibit editsection links if requested in the page if ( isset( $this->mDoubleUnderscores['noeditsection'] ) ) { @@ -4309,7 +4309,7 @@ # Save headline for section edit hint before it's escaped $headlineHint = $safeHeadline; - if ( $wgHtml5 && $wgExperimentalHtmlIds ) { + if ( $wgExperimentalHtmlIds ) { # For reverse compatibility, provide an id that's # HTML4-compatible, like we used to. # diff --git a/tests/phpunit/includes/HtmlTest.php b/tests/phpunit/includes/HtmlTest.php index 4e010d4..ecfe418 100644 --- a/tests/phpunit/includes/HtmlTest.php +++ b/tests/phpunit/includes/HtmlTest.php @@ -37,7 +37,6 @@ 'wgLanguageCode' => $langCode, 'wgContLang' => $langObj, 'wgLang' => $langObj, - 'wgHtml5' => true, 'wgWellFormedXml' => false, ) ); } @@ -68,6 +67,31 @@ Html::element( 'img', null, '' ), 'Self-closing tag for short-tag elements (wgWellFormedXml = true)' ); + } + + public function dataXmlMimeType() { + return array( + // ( $mimetype, $isXmlMimeType ) + # HTML is not an XML MimeType + array( 'text/html', false ), + # XML is an XML MimeType + array( 'text/xml', true ), + array( 'application/xml', true ), + # XHTML is an XML MimeType + array( 'application/xhtml+xml', true ), + # Make sure other +xml MimeTypes are supported + # SVG is another random MimeType even though we don't use it + array( 'image/svg+xml', true ), + # Complete random other MimeTypes are not XML + array( 'text/plain', false ), + ); + } + + /** + * @dataProvider dataXmlMimeType + */ + public function testXmlMimeType( $mimetype, $isXmlMimeType ) { + $this->assertEquals( $isXmlMimeType, Html::isXmlMimeType( $mimetype ) ); } public function testExpandAttributesSkipsNullAndFalse() { @@ -116,14 +140,6 @@ ' selected=""', Html::expandAttributes( array( 'selected' => true ) ), 'Boolean attributes have empty string value when value is true (wgWellFormedXml)' - ); - - $this->setMwGlobals( 'wgHtml5', false ); - - $this->assertEquals( - ' selected="selected"', - Html::expandAttributes( array( 'selected' => true ) ), - 'Boolean attributes have their key as value when value is true (wgWellFormedXml, wgHTML5 = false)' ); } diff --git a/tests/phpunit/includes/SanitizerTest.php b/tests/phpunit/includes/SanitizerTest.php index c84f10c..14b3c0c 100644 --- a/tests/phpunit/includes/SanitizerTest.php +++ b/tests/phpunit/includes/SanitizerTest.php @@ -71,8 +71,6 @@ */ function testRemovehtmltagsOnHtml5Tags( $tag, $escaped ) { $this->setMwGlobals( array( - # Enable HTML5 mode - 'wgHtml5' => true, 'wgUseTidy' => false ) ); diff --git a/tests/phpunit/includes/XmlSelectTest.php b/tests/phpunit/includes/XmlSelectTest.php index d7227b4..08c031f 100644 --- a/tests/phpunit/includes/XmlSelectTest.php +++ b/tests/phpunit/includes/XmlSelectTest.php @@ -7,7 +7,6 @@ protected function setUp() { parent::setUp(); $this->setMwGlobals( array( - 'wgHtml5' => true, 'wgWellFormedXml' => true, ) ); $this->select = new XmlSelect(); diff --git a/tests/phpunit/includes/XmlTest.php b/tests/phpunit/includes/XmlTest.php index f482328..2294804 100644 --- a/tests/phpunit/includes/XmlTest.php +++ b/tests/phpunit/includes/XmlTest.php @@ -29,7 +29,6 @@ $this->setMwGlobals( array( 'wgLang' => $langObj, - 'wgHtml5' => true, 'wgWellFormedXml' => true, ) ); } diff --git a/tests/phpunit/includes/parser/NewParserTest.php b/tests/phpunit/includes/parser/NewParserTest.php index d66fac7..ab1c0e9 100644 --- a/tests/phpunit/includes/parser/NewParserTest.php +++ b/tests/phpunit/includes/parser/NewParserTest.php @@ -83,7 +83,6 @@ $tmpGlobals['wgRawHtml'] = false; $tmpGlobals['wgUseTidy'] = false; $tmpGlobals['wgAlwaysUseTidy'] = false; - $tmpGlobals['wgHtml5'] = true; $tmpGlobals['wgWellFormedXml'] = true; $tmpGlobals['wgAllowMicrodataAttributes'] = true; $tmpGlobals['wgExperimentalHtmlIds'] = false; -- To view, visit https://gerrit.wikimedia.org/r/63106 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iad9634e2ee420b5a3bbffe550421fde4fa1819b0 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Daniel Friesen <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
