From b8a840974455ec58dfb395f30d6e6e54980856e0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Sun, 24 Jul 2016 22:28:56 +0200 Subject: [PATCH] mw.Title: Use $wgIllegalFileChars for file title checking mw.Title.newFromFileName() will now correctly use $wgIllegalFileChars, rather than partially and incorrectly duplicating it. $wgIllegalFileChars is currently defined to contain ':', '/' and '\'. Previously we incorrectly did not filter out backslashes '\'. The hash '#' is already disallowed by $wgLegalTitleChars. Bug: T140222 Change-Id: I17e3ef61e04ae002ef576c9416c8f265ee000e89 --- includes/resourceloader/ResourceLoaderStartUpModule.php | 3 +++ resources/src/mediawiki/mediawiki.Title.js | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/includes/resourceloader/ResourceLoaderStartUpModule.php b/includes/resourceloader/ResourceLoaderStartUpModule.php index 7b2d532d13..eb9788c0ce 100644 --- a/includes/resourceloader/ResourceLoaderStartUpModule.php +++ b/includes/resourceloader/ResourceLoaderStartUpModule.php @@ -66,6 +66,8 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule { } } + $illegalFileChars = $conf->get( 'IllegalFileChars' ); + // Build list of variables $vars = [ 'wgLoadScript' => wfScript( 'load' ), @@ -107,6 +109,7 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule { 'wgResourceLoaderMaxQueryLength' => $conf->get( 'ResourceLoaderMaxQueryLength' ), 'wgCaseSensitiveNamespaces' => $caseSensitiveNamespaces, 'wgLegalTitleChars' => Title::convertByteClassToUnicodeClass( Title::legalChars() ), + 'wgIllegalFileChars' => Title::convertByteClassToUnicodeClass( $illegalFileChars ), 'wgResourceLoaderStorageVersion' => $conf->get( 'ResourceLoaderStorageVersion' ), 'wgResourceLoaderStorageEnabled' => $conf->get( 'ResourceLoaderStorageEnabled' ), 'wgResourceLoaderLegacyModules' => self::getLegacyModules(), diff --git a/resources/src/mediawiki/mediawiki.Title.js b/resources/src/mediawiki/mediawiki.Title.js index ff4d1c20cb..4c57faa6c8 100644 --- a/resources/src/mediawiki/mediawiki.Title.js +++ b/resources/src/mediawiki/mediawiki.Title.js @@ -213,7 +213,7 @@ }, // slash, colon (not supported by file systems like NTFS/Windows, Mac OS 9 [:], ext4 [/]) { - pattern: /[:\/#]/g, + pattern: new RegExp( '[' + mw.config.get( 'wgIllegalFileChars', '' ) + ']', 'g' ), replace: '-', fileRule: true }, -- 2.20.1