'ResourceLoaderFilePath' => __DIR__ . '/includes/resourceloader/ResourceLoaderFilePath.php',
'ResourceLoaderImage' => __DIR__ . '/includes/resourceloader/ResourceLoaderImage.php',
'ResourceLoaderImageModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderImageModule.php',
+ 'ResourceLoaderJqueryMsgDataModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderJqueryMsgDataModule.php',
'ResourceLoaderLanguageDataModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderLanguageDataModule.php',
'ResourceLoaderLanguageNamesModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderLanguageNamesModule.php',
'ResourceLoaderModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderModule.php',
}
/**
- * Cleans up HTML, removes dangerous tags and attributes, and
- * removes HTML comments
- * @param string $text
- * @param callable $processCallback Callback to do any variable or parameter
- * replacements in HTML attribute values
- * @param array|bool $args Arguments for the processing callback
+ * Return the various lists of recognized tags
* @param array $extratags For any extra tags to include
* @param array $removetags For any tags (default or extra) to exclude
- * @return string
+ * @return array
*/
- public static function removeHTMLtags( $text, $processCallback = null,
- $args = array(), $extratags = array(), $removetags = array()
- ) {
- global $wgUseTidy, $wgAllowMicrodataAttributes, $wgAllowImageTag;
+ public static function getRecognizedTagData( $extratags = array(), $removetags = array() ) {
+ global $wgAllowMicrodataAttributes, $wgAllowImageTag;
static $htmlpairsStatic, $htmlsingle, $htmlsingleonly, $htmlnest, $tabletags,
$htmllist, $listtags, $htmlsingleallowed, $htmlelementsStatic, $staticInitialised;
}
$staticInitialised = $globalContext;
}
+
# Populate $htmlpairs and $htmlelements with the $extratags and $removetags arrays
$extratags = array_flip( $extratags );
$removetags = array_flip( $removetags );
$htmlpairs = array_merge( $extratags, $htmlpairsStatic );
$htmlelements = array_diff_key( array_merge( $extratags, $htmlelementsStatic ), $removetags );
+ return array(
+ 'htmlpairs' => $htmlpairs,
+ 'htmlsingle' => $htmlsingle,
+ 'htmlsingleonly' => $htmlsingleonly,
+ 'htmlnest' => $htmlnest,
+ 'tabletags' => $tabletags,
+ 'htmllist' => $htmllist,
+ 'listtags' => $listtags,
+ 'htmlsingleallowed' => $htmlsingleallowed,
+ 'htmlelements' => $htmlelements,
+ );
+ }
+
+ /**
+ * Cleans up HTML, removes dangerous tags and attributes, and
+ * removes HTML comments
+ * @param string $text
+ * @param callable $processCallback Callback to do any variable or parameter
+ * replacements in HTML attribute values
+ * @param array|bool $args Arguments for the processing callback
+ * @param array $extratags For any extra tags to include
+ * @param array $removetags For any tags (default or extra) to exclude
+ * @return string
+ */
+ public static function removeHTMLtags( $text, $processCallback = null,
+ $args = array(), $extratags = array(), $removetags = array()
+ ) {
+ global $wgUseTidy;
+
+ extract( self::getRecognizedTagData( $extratags, $removetags ) );
+
# Remove HTML comments
$text = Sanitizer::removeHTMLcomments( $text );
$bits = explode( '<', $text );
isset( $metadata[self::META_BC_SUBELEMENTS] )
) {
foreach ( $metadata[self::META_BC_SUBELEMENTS] as $k ) {
- $data[$k] = array(
- '*' => $data[$k],
- self::META_CONTENT => '*',
- self::META_TYPE => 'assoc',
- );
+ if ( isset( $data[$k] ) ) {
+ $data[$k] = array(
+ '*' => $data[$k],
+ self::META_CONTENT => '*',
+ self::META_TYPE => 'assoc',
+ );
+ }
}
}
// $wgLogo is probably wrong (bug 48084); set something that will work.
// Single quotes work fine here, as LocalSettingsGenerator outputs this unescaped.
- 'wgLogo' => '$wgScriptPath/resources/assets/wiki.png',
+ 'wgLogo' => '$wgResourceBasePath/resources/assets/wiki.png',
);
/**
public $licenses = array(
'cc-by' => array(
'url' => 'https://creativecommons.org/licenses/by/3.0/',
- 'icon' => '{$wgResourceBasePath}/resources/assets/licenses/cc-by.png',
+ 'icon' => '$wgResourceBasePath/resources/assets/licenses/cc-by.png',
),
'cc-by-sa' => array(
'url' => 'https://creativecommons.org/licenses/by-sa/3.0/',
- 'icon' => '{$wgResourceBasePath}/resources/assets/licenses/cc-by-sa.png',
+ 'icon' => '$wgResourceBasePath/resources/assets/licenses/cc-by-sa.png',
),
'cc-by-nc-sa' => array(
'url' => 'https://creativecommons.org/licenses/by-nc-sa/3.0/',
- 'icon' => '{$wgResourceBasePath}/resources/assets/licenses/cc-by-nc-sa.png',
+ 'icon' => '$wgResourceBasePath/resources/assets/licenses/cc-by-nc-sa.png',
),
'cc-0' => array(
'url' => 'https://creativecommons.org/publicdomain/zero/1.0/',
- 'icon' => '{$wgResourceBasePath}/resources/assets/licenses/cc-0.png',
+ 'icon' => '$wgResourceBasePath/resources/assets/licenses/cc-0.png',
),
'pd' => array(
'url' => '',
- 'icon' => '{$wgResourceBasePath}/resources/assets/licenses/public-domain.png',
+ 'icon' => '$wgResourceBasePath/resources/assets/licenses/public-domain.png',
),
'gfdl' => array(
'url' => 'https://www.gnu.org/copyleft/fdl.html',
- 'icon' => '{$wgResourceBasePath}/resources/assets/licenses/gnu-fdl.png',
+ 'icon' => '$wgResourceBasePath/resources/assets/licenses/gnu-fdl.png',
),
'none' => array(
'url' => '',
${serverSetting}
## The relative URL path to the skins directory
\$wgStylePath = \"\$wgScriptPath/skins\";
+\$wgResourceBasePath = \$wgScriptPath;
## The relative URL path to the logo. Make sure you change this from the default,
## or else you'll overwrite your logo when you upgrade!
) );
$styleUrl = $server . dirname( dirname( $this->parent->getUrl() ) ) .
'/mw-config/config-cc.css';
- $iframeUrl = 'https://creativecommons.org/license/?' .
+ $iframeUrl = '//creativecommons.org/license/?' .
wfArrayToCgi( array(
'partner' => 'MediaWiki',
'exit_url' => $exitUrl,
"config-magic-quotes-sybase": "<strong>Fatal: [http://www.php.net/manual/en/ref.info.php#ini.magic-quotes-sybase magic_quotes_sybase] is active!</strong>\nThis option corrupts data input unpredictably.\nYou cannot install or use MediaWiki unless this option is disabled.",
"config-mbstring": "<strong>Fatal: [http://www.php.net/manual/en/ref.mbstring.php#mbstring.overload mbstring.func_overload] is active!</strong>\nThis option causes errors and may corrupt data unpredictably.\nYou cannot install or use MediaWiki unless this option is disabled.",
"config-safe-mode": "<strong>Warning:</strong> PHP's [http://www.php.net/features.safe-mode safe mode] is active.\nIt may cause problems, particularly if using file uploads and <code>math</code> support.",
- "config-xml-bad": "PHP's XML module is missing.\nMediaWiki requires functions in this module and will not work in this configuration.\nIf you're running Mandrake, install the php-xml package.",
+ "config-xml-bad": "PHP's XML module is missing.\nMediaWiki requires functions in this module and will not work in this configuration.\nYou may need to install the php-xml RPM package.",
"config-pcre-old": "<strong>Fatal:</strong> PCRE $1 or later is required.\nYour PHP binary is linked with PCRE $2.\n[https://www.mediawiki.org/wiki/Manual:Errors_and_symptoms/PCRE More information].",
"config-pcre-no-utf8": "<strong>Fatal:</strong> PHP's PCRE module seems to be compiled without PCRE_UTF8 support.\nMediaWiki requires UTF-8 support to function correctly.",
"config-memory-raised": "PHP's <code>memory_limit</code> is $1, raised to $2.",
--- /dev/null
+<?php
+/**
+ * Resource loader module for populating mediawiki.jqueryMsg data.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @author Brad Jorsch
+ */
+
+/**
+ * ResourceLoader module for populating mediawiki.jqueryMsg data.
+ */
+class ResourceLoaderJqueryMsgDataModule extends ResourceLoaderModule {
+
+ protected $targets = array( 'desktop', 'mobile' );
+
+ /**
+ * @param ResourceLoaderContext $context
+ * @return string JavaScript code
+ */
+ public function getScript( ResourceLoaderContext $context ) {
+ $jsData = array();
+
+ $tagData = Sanitizer::getRecognizedTagData();
+ $jsData['allowedHtmlElements'] = array_merge(
+ array_keys( $tagData['htmlpairs'] ),
+ array_diff(
+ array_keys( $tagData['htmlsingle'] ),
+ array_keys( $tagData['htmlsingleonly'] )
+ )
+ );
+
+ return "if ( !mw.jqueryMsg ) {\n" .
+ "\tmw.jqueryMsg = {};\n" .
+ "}\n" .
+ "mw.jqueryMsg.data = " . Xml::encodeJsVar( $jsData ) . ";\n";
+ }
+
+ /**
+ * @param ResourceLoaderContext $context
+ * @return array|null
+ */
+ public function getDefinitionSummary( ResourceLoaderContext $context ) {
+ $ret = parent::getDefinitionSummary( $context );
+ $ret['hash'] = md5( $this->getScript( $context ) );
+ return $ret;
+ }
+}
// Scripts for the dynamic language specific data, like grammar forms.
'mediawiki.language.data' => array( 'class' => 'ResourceLoaderLanguageDataModule' ),
+ // Dynamic data for mediawiki.jqueryMsg, such as allowed tags
+ 'mediawiki.jqueryMsg.data' => array( 'class' => 'ResourceLoaderJqueryMsgDataModule' ),
+
/* MediaWiki base skinning modules */
/**
'mediawiki.jqueryMsg' => array(
'scripts' => 'resources/src/mediawiki/mediawiki.jqueryMsg.js',
'dependencies' => array(
+ 'mediawiki.jqueryMsg.data',
'mediawiki.util',
'mediawiki.language',
'dom-level2-shim',
magic: {
'SITENAME': mw.config.get( 'wgSiteName' )
},
- // This is a whitelist based on, but simpler than, Sanitizer.php.
+ // This is a whitelist like Sanitizer.php.
// Self-closing tags are not currently supported.
+ // The simplified default here is overridden below by data supplied
+ // by the mediawiki.jqueryMsg.data module.
allowedHtmlElements: [
'b',
'i'
};
}
+ // Use data from mediawiki.jqueryMsg.data to override defaults, if
+ // available
+ if ( mw.jqueryMsg && mw.jqueryMsg.data ) {
+ if ( mw.jqueryMsg.data.allowedHtmlElements ) {
+ parserDefaults.allowedHtmlElements = mw.jqueryMsg.data.allowedHtmlElements;
+ }
+ }
+
mw.jqueryMsg = {};
/**