From 97caae596d5493ea2f3e4ba505204a7e278d0590 Mon Sep 17 00:00:00 2001 From: Daniel Friesen Date: Thu, 9 May 2013 21:04:33 -0700 Subject: [PATCH] Drop support for XHTML 1.0 * $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 --- RELEASE-NOTES-1.22 | 8 + includes/DefaultSettings.php | 53 +++--- includes/GlobalFunctions.php | 2 +- includes/Html.php | 158 ++++++------------ includes/OutputHandler.php | 48 +++--- includes/OutputPage.php | 19 +-- includes/PHPVersionError.php | 8 +- includes/Sanitizer.php | 64 ++++--- includes/Setup.php | 9 +- includes/SkinTemplate.php | 4 +- includes/User.php | 3 +- includes/parser/Parser.php | 6 +- includes/templates/NoLocalSettings.php | 8 +- languages/messages/MessagesEn.php | 4 +- maintenance/fuzz-tester.php | 2 +- maintenance/renderDump.php | 7 +- tests/phpunit/includes/HtmlTest.php | 34 +++- tests/phpunit/includes/SanitizerTest.php | 2 - tests/phpunit/includes/XmlSelectTest.php | 1 - tests/phpunit/includes/XmlTest.php | 1 - .../phpunit/includes/parser/NewParserTest.php | 1 - 21 files changed, 187 insertions(+), 255 deletions(-) diff --git a/RELEASE-NOTES-1.22 b/RELEASE-NOTES-1.22 index 6b66ce0870..f9866f8152 100644 --- a/RELEASE-NOTES-1.22 +++ b/RELEASE-NOTES-1.22 @@ -18,6 +18,11 @@ production. * $wgCascadingRestrictionLevels was added. * ftps, ssh, sftp, xmpp, sip, sips, tel, sms, bitcoin, magnet, urn, and geo have been whitelisted inside of $wgUrlProtocols. +* $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. @@ -72,6 +77,8 @@ production. uses ES5 getter/setter to emit a warning when they are used. * $wgCascadingRestrictionLevels was added, allowing one to specify restriction levels which can be cascading (previously 'sysop' was hard-coded as the only one). +* 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 is false. Previously one @@ -155,6 +162,7 @@ changes to languages because of Bugzilla reports. 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.0 has been removed. MediaWiki now only outputs (X)HTML5. == Compatibility == diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 296b71d1a2..2cb0a36021 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -2518,48 +2518,36 @@ $wgLocalTZoffset = null; $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 - * doesn't actually have a doctype part to put this variable's contents in. - */ -$wgDocType = '-//W3C//DTD XHTML 1.0 Transitional//EN'; - -/** - * The URL of the document type declaration. Ignored if $wgHtml5 is true, - * since HTML5 has no DTD, and 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? + * 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 since 1.22 */ -$wgXhtmlDefaultNamespace = 'http://www.w3.org/1999/xhtml'; +$wgXhtmlDefaultNamespace = null; /** - * 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 since 1.22 */ $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 @@ $wgHtml5Version = null; $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 @@ $wgWellFormedXml = true; * Normally we wouldn't have to define this in the root "" * 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/GlobalFunctions.php b/includes/GlobalFunctions.php index 5c45577ee6..78fcb8b941 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -1674,7 +1674,7 @@ function wfMsgExt( $key, $options ) { /** * Since wfMsg() and co suck, they don't return false if the message key they - * looked up didn't exist but a XHTML string, this function checks for the + * looked up didn't exist but instead the key wrapped in <>'s, this function checks for the * nonexistence of messages by checking the MessageCache::get() result directly. * * @deprecated since 1.18. Use Message::isDisabled(). diff --git a/includes/Html.php b/includes/Html.php index cb082a18ac..e7455b7559 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.). * @@ -101,19 +101,6 @@ class Html { 'itemscope', ); - private static $HTMLFiveOnlyAttribs = array( - 'autocomplete', - 'autofocus', - 'max', - 'min', - 'multiple', - 'pattern', - 'placeholder', - 'required', - 'step', - 'spellcheck', - ); - /** * Returns an HTML element in a string. The major advantage here over * manually typing out the HTML is that it will escape all attribute @@ -177,7 +164,7 @@ class Html { * @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,36 +191,28 @@ class Html { '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