Bug 20489 Configure illegal file characters https://bugzilla.wikimedia.org/show_bug...
authorJack D. Pond <jdpond@users.mediawiki.org>
Fri, 4 Sep 2009 03:44:14 +0000 (03:44 +0000)
committerJack D. Pond <jdpond@users.mediawiki.org>
Fri, 4 Sep 2009 03:44:14 +0000 (03:44 +0000)
$wgIllegalFileChars configurable to add chars for filename automatically converted to "-".

includes/DefaultSettings.php
includes/GlobalFunctions.php

index a696564..d0b806f 100644 (file)
@@ -288,6 +288,7 @@ $wgForeignFileRepos = array();
  * this breaks interlanguage links
  */
 $wgLegalTitleChars = " %!\"$&'()*,\\-.\\/0-9:;=?@A-Z\\\\^_`a-z~\\x80-\\xFF+";
+$wgIllegalFileChars = ":";  // These are additional characters that should be replaced with '-' in file names
 
 /**
  * The external URL protocols
index e1eb6ab..4cbed9e 100644 (file)
@@ -3228,8 +3228,9 @@ function wfGenerateToken( $salt = '' ) {
  * @param $name Mixed: filename to process
  */
 function wfStripIllegalFilenameChars( $name ) {
+       global $wgIllegalFileChars;
        $name = wfBaseName( $name );
-       $name = preg_replace ( "/[^".Title::legalChars()."]|:/", '-', $name );
+       $name = preg_replace("/[^".Title::legalChars()."]".($wgIllegalFileChars ? "|[".$wgIllegalFileChars."]":"")."/",'-',$name);
        return $name;
 }