r59035 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59034‎ | r59035 | r59036 >
Date:22:09, 13 November 2009
Author:daniel
Status:ok (Comments)
Tags:
Comment:
use newer spec for html5 metadata
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/Sanitizer.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Sanitizer.php
@@ -650,11 +650,12 @@
651651 $wgEnforceHtmlIds ? 'noninitial' : 'xml' );
652652 }
653653
654 - //RDFa and microdata properties allow URIs. check them
 654+ //RDFa and microdata properties allow URLs, URIs and/or CURIs. check them for sanity
655655 if ( $attribute === 'rel' || $attribute === 'rev' ||
656 - $attribute === 'about' || $attribute === 'property' || $attribute === 'resource' ||
657 - $attribute === 'datatype' || $attribute === 'typeof' ||
658 - $attribute === 'item' || $attribute === 'itemprop' || $attribute === 'subject' ) {
 656+ $attribute === 'about' || $attribute === 'property' || $attribute === 'resource' || #RDFa
 657+ $attribute === 'datatype' || $attribute === 'typeof' || #RDFa
 658+ $attribute === 'itemid' || $attribute === 'itemprop' || $attribute === 'itemref' || #HTML5 microdata
 659+ $attribute === 'itemscope' || $attribute === 'itemtype' ) { #HTML5 microdata
659660
660661 //Paranoia. Allow "simple" values but suppress javascript
661662 if ( preg_match( MW_EVIL_URI_PATTERN, $value ) ) {
@@ -1199,7 +1200,7 @@
12001201 * @return Array
12011202 */
12021203 static function setupAttributeWhitelist() {
1203 - global $wgAllowRdfaAttributes, $wgHtml5, $wgAllowItemAttributes;
 1204+ global $wgAllowRdfaAttributes, $wgHtml5, $wgAllowMicrodataAttributes;
12041205
12051206 $common = array( 'id', 'class', 'lang', 'dir', 'title', 'style', 'xml:lang' );
12061207
@@ -1210,10 +1211,10 @@
12111212 ) );
12121213 }
12131214
1214 - if ( $wgHtml5 && $wgAllowItemAttributes ) {
1215 - # add HTML5 microdata tages as pecified by http://www.w3.org/TR/html5/microdata.html
 1215+ if ( $wgHtml5 && $wgAllowMicrodataAttributes ) {
 1216+ # add HTML5 microdata tages as pecified by http://www.whatwg.org/specs/web-apps/current-work/multipage/microdata.html#the-microdata-model
12161217 $common = array_merge( $common, array(
1217 - 'item', 'itemprop', 'subject'
 1218+ 'itemid', 'itemprop', 'itemref', 'itemscope', 'itemtype'
12181219 ) );
12191220 }
12201221
Index: trunk/phase3/includes/DefaultSettings.php
@@ -921,14 +921,15 @@
922922 $wgHtml5Version = null;
923923
924924 /**
925 - * Enabled RDFa attributes for use in wikitext.
 925+ * Enabled RDFa attributes for use in wikitext.
 926+ * NOTE: Interaction with HTML5 is somewhat underspecified.
926927 */
927928 $wgAllowRdfaAttributes = true;
928929
929930 /**
930 - * Enabled HTML 5 data attributes for use in wikitext, if $wgHtml5 is also true.
 931+ * Enabled HTML 5 microdata attributes for use in wikitext, if $wgHtml5 is also true.
931932 */
932 -$wgAllowItemAttributes = true;
 933+$wgAllowMicrodataAttributes = true;
933934
934935 /**
935936 * Should we try to make our HTML output well-formed XML? If set to false,

Comments

#Comment by Platonides (talk | contribs)   00:00, 16 January 2010

There should be an array of RDFa attributes and another of MicrodataAttributes. And then in_array() / array_merge from them as appropiate. It could even be premerged at an early stage, stored at a static var. Not sure what would be the equivalent of Setup.php restricted to the parser.

Related revisions: r58712 & 59024

Status & tagging log