jenkins-bot has submitted this change and it was merged. Change subject: Remove $wgAllowMicroDataAttributes and $wgAllowRdfaAttributes ......................................................................
Remove $wgAllowMicroDataAttributes and $wgAllowRdfaAttributes $wgAllowMicroDataAttributes and $wgAllowRdfaAttributes have been introduced in MediaWiki 1.16 and required at this moment $wgHTML5 to be true. This last setting has been removed in MediaWiki 1.22. To simplify the code maintenance and the configuration complexity, those settings are removed and the features are always available. RDFa users must now explicitly set $wgHtml5Version to a RDFa version. Currently the correct values are: - HTML+RDFa 1.0 - XHTML+RDFa 1.0 Bug: T130040 Change-Id: I17a7bff2cad170e381eabf0aec4e26e4fd0cddc3 --- M RELEASE-NOTES-1.27 M includes/DefaultSettings.php M includes/Sanitizer.php M includes/Setup.php M tests/parser/parserTest.inc M tests/parser/parserTests.txt M tests/phpunit/includes/parser/NewParserTest.php 7 files changed, 40 insertions(+), 65 deletions(-) Approvals: Daniel Kinzler: Looks good to me, approved jenkins-bot: Verified diff --git a/RELEASE-NOTES-1.27 b/RELEASE-NOTES-1.27 index d8866ad..1ec1962 100644 --- a/RELEASE-NOTES-1.27 +++ b/RELEASE-NOTES-1.27 @@ -10,6 +10,9 @@ HHVM 3.1. === Configuration changes in 1.27 === +* $wgAllowMicrodataAttributes and $wgAllowRdfaAttributes were removed, + now always enabled. If you use RDFa on your wiki, you now have to explicitly + set $wgHtml5Version to 'HTML+RDFa 1.0' or 'XHTML+RDFa 1.0'. * $wgUseLinkNamespaceDBFields was removed. * Deprecated $wgResourceLoaderMinifierStatementsOnOwnLine and $wgResourceLoaderMinifierMaxLineLength, because there was little value in diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index c04602c..f2a3f97 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -3081,10 +3081,11 @@ /** * Defines the value of the version attribute in the <html> tag, if any. - * 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. + * + * If your wiki uses RDFa, set it to the correct value for RDFa+HTML5. + * Correct current values are 'HTML+RDFa 1.0' or 'XHTML+RDFa 1.0'. + * See also http://www.w3.org/TR/rdfa-in-html/#document-conformance + * @since 1.16 */ $wgHtml5Version = null; @@ -3104,17 +3105,6 @@ * @since 1.24 */ $wgUseMediaWikiUIEverywhere = false; - -/** - * Enabled RDFa attributes for use in wikitext. - * NOTE: Interaction with HTML5 is somewhat underspecified. - */ -$wgAllowRdfaAttributes = false; - -/** - * Enabled HTML5 microdata attributes for use in wikitext. - */ -$wgAllowMicrodataAttributes = false; /** * Should we try to make our HTML output well-formed XML? If set to false, diff --git a/includes/Sanitizer.php b/includes/Sanitizer.php index d52bc07..d321e9f 100644 --- a/includes/Sanitizer.php +++ b/includes/Sanitizer.php @@ -363,14 +363,14 @@ * @return array */ public static function getRecognizedTagData( $extratags = [], $removetags = [] ) { - global $wgAllowMicrodataAttributes, $wgAllowImageTag; + global $wgAllowImageTag; static $htmlpairsStatic, $htmlsingle, $htmlsingleonly, $htmlnest, $tabletags, $htmllist, $listtags, $htmlsingleallowed, $htmlelementsStatic, $staticInitialised; // 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( 'wgAllowMicrodataAttributes', 'wgAllowImageTag' ) ); + $globalContext = $wgAllowImageTag; if ( !$staticInitialised || $staticInitialised != $globalContext ) { $htmlpairsStatic = [ # Tags that must be closed 'b', 'bdi', 'del', 'i', 'ins', 'u', 'font', 'big', 'small', 'sub', 'sup', 'h1', @@ -386,10 +386,10 @@ $htmlsingleonly = [ # Elements that cannot have close tags 'br', 'wbr', 'hr' ]; - if ( $wgAllowMicrodataAttributes ) { - $htmlsingle[] = $htmlsingleonly[] = 'meta'; - $htmlsingle[] = $htmlsingleonly[] = 'link'; - } + + $htmlsingle[] = $htmlsingleonly[] = 'meta'; + $htmlsingle[] = $htmlsingleonly[] = 'link'; + $htmlnest = [ # Tags that can be nested--?? 'table', 'tr', 'td', 'th', 'div', 'blockquote', 'ol', 'ul', 'li', 'dl', 'dt', 'dd', 'font', 'big', 'small', 'sub', 'sup', 'span', @@ -734,15 +734,13 @@ * @todo Check for unique id attribute :P */ static function validateAttributes( $attribs, $whitelist ) { - global $wgAllowRdfaAttributes, $wgAllowMicrodataAttributes; - $whitelist = array_flip( $whitelist ); $hrefExp = '/^(' . wfUrlProtocols() . ')[^\s]+$/'; $out = []; foreach ( $attribs as $attribute => $value ) { - # allow XML namespace declaration if RDFa is enabled - if ( $wgAllowRdfaAttributes && preg_match( self::XMLNS_ATTRIBUTE_PATTERN, $attribute ) ) { + # Allow XML namespace declaration to allow RDFa + if ( preg_match( self::XMLNS_ATTRIBUTE_PATTERN, $attribute ) ) { if ( !preg_match( self::EVIL_URI_PATTERN, $value ) ) { $out[$attribute] = $value; } @@ -817,15 +815,14 @@ $out[$attribute] = $value; } - if ( $wgAllowMicrodataAttributes ) { - # itemtype, itemid, itemref don't make sense without itemscope - if ( !array_key_exists( 'itemscope', $out ) ) { - unset( $out['itemtype'] ); - unset( $out['itemid'] ); - unset( $out['itemref'] ); - } - # TODO: Strip itemprop if we aren't descendants of an itemscope or pointed to by an itemref. + # itemtype, itemid, itemref don't make sense without itemscope + if ( !array_key_exists( 'itemscope', $out ) ) { + unset( $out['itemtype'] ); + unset( $out['itemid'] ); + unset( $out['itemref'] ); } + # TODO: Strip itemprop if we aren't descendants of an itemscope or pointed to by an itemref. + return $out; } @@ -1561,12 +1558,9 @@ * @return array */ static function setupAttributeWhitelist() { - global $wgAllowRdfaAttributes, $wgAllowMicrodataAttributes; - static $whitelist, $staticInitialised; + static $whitelist; - $globalContext = implode( '-', compact( 'wgAllowRdfaAttributes', 'wgAllowMicrodataAttributes' ) ); - - if ( $whitelist !== null && $staticInitialised == $globalContext ) { + if ( $whitelist !== null ) { return $whitelist; } @@ -1586,23 +1580,24 @@ 'aria-labelledby', 'aria-owns', 'role', - ]; - if ( $wgAllowRdfaAttributes ) { - # RDFa attributes as specified in section 9 of + # RDFa + # These attributes are specified in section 9 of # http://www.w3.org/TR/2008/REC-rdfa-syntax-20081014 - $common = array_merge( $common, [ - 'about', 'property', 'resource', 'datatype', 'typeof', - ] ); - } + 'about', + 'property', + 'resource', + 'datatype', + 'typeof', - if ( $wgAllowMicrodataAttributes ) { - # add HTML5 microdata tags as specified by + # Microdata. These are specified by # http://www.whatwg.org/html/microdata.html#the-microdata-model - $common = array_merge( $common, [ - 'itemid', 'itemprop', 'itemref', 'itemscope', 'itemtype' - ] ); - } + 'itemid', + 'itemprop', + 'itemref', + 'itemscope', + 'itemtype', + ]; $block = array_merge( $common, [ 'align' ] ); $tablealign = [ 'align', 'valign' ]; @@ -1772,8 +1767,6 @@ 'meta' => [ 'itemprop', 'content' ], 'link' => [ 'itemprop', 'href' ], ]; - - $staticInitialised = $globalContext; return $whitelist; } diff --git a/includes/Setup.php b/includes/Setup.php index f26d789..2585738 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -443,15 +443,6 @@ $wgXhtmlDefaultNamespace = 'http://www.w3.org/1999/xhtml'; $wgJsMimeType = 'text/javascript'; -if ( !$wgHtml5Version && $wgAllowRdfaAttributes ) { - // see http://www.w3.org/TR/rdfa-in-html/#document-conformance - if ( $wgMimeType == 'application/xhtml+xml' ) { - $wgHtml5Version = 'XHTML+RDFa 1.0'; - } else { - $wgHtml5Version = 'HTML+RDFa 1.0'; - } -} - // Blacklisted file extensions shouldn't appear on the "allowed" list $wgFileExtensions = array_values( array_diff( $wgFileExtensions, $wgFileBlacklist ) ); diff --git a/tests/parser/parserTest.inc b/tests/parser/parserTest.inc index 9f45307..c10d3f7 100644 --- a/tests/parser/parserTest.inc +++ b/tests/parser/parserTest.inc @@ -896,7 +896,6 @@ 'wgExternalLinkTarget' => false, 'wgHtml5' => true, 'wgWellFormedXml' => true, - 'wgAllowMicrodataAttributes' => true, 'wgAdaptiveMessageCache' => true, 'wgDisableLangConversion' => false, 'wgDisableTitleConversion' => false, diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index d01ebdf..356eed3 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -24664,7 +24664,7 @@ !! wikitext <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">MediaWiki</span> !! html/php -<p><span>MediaWiki</span> +<p><span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">MediaWiki</span> </p> !! html/parsoid <p><span xmlns:dct="http://purl.org/dc/terms/" data-x-property="dct:title" data-parsoid='{"stx":"html"}'>MediaWiki</span></p> diff --git a/tests/phpunit/includes/parser/NewParserTest.php b/tests/phpunit/includes/parser/NewParserTest.php index 4eb480d..0ad4b27 100644 --- a/tests/phpunit/includes/parser/NewParserTest.php +++ b/tests/phpunit/includes/parser/NewParserTest.php @@ -102,7 +102,6 @@ $tmpGlobals['wgAllowExternalImages'] = true; $tmpGlobals['wgRawHtml'] = false; $tmpGlobals['wgWellFormedXml'] = true; - $tmpGlobals['wgAllowMicrodataAttributes'] = true; $tmpGlobals['wgExperimentalHtmlIds'] = false; $tmpGlobals['wgAdaptiveMessageCache'] = true; $tmpGlobals['wgUseDatabaseMessages'] = true; -- To view, visit https://gerrit.wikimedia.org/r/277562 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I17a7bff2cad170e381eabf0aec4e26e4fd0cddc3 Gerrit-PatchSet: 8 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Dereckson <[email protected]> Gerrit-Reviewer: Cscott <[email protected]> Gerrit-Reviewer: Daniel Friesen <[email protected]> Gerrit-Reviewer: Daniel Kinzler <[email protected]> Gerrit-Reviewer: Danny B. <[email protected]> Gerrit-Reviewer: Dereckson <[email protected]> Gerrit-Reviewer: Jackmcbarn <[email protected]> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
