r55802 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r55801‎ | r55802 | r55803 >
Date:03:44, 4 September 2009
Author:jdpond
Status:ok
Tags:
Comment:
Bug 20489 Configure illegal file characters https://bugzilla.wikimedia.org/show_bug.cgi?id=20489
$wgIllegalFileChars configurable to add chars for filename automatically converted to "-".
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/DefaultSettings.php
@@ -288,6 +288,7 @@
289289 * this breaks interlanguage links
290290 */
291291 $wgLegalTitleChars = " %!\"$&'()*,\\-.\\/0-9:;=?@A-Z\\\\^_`a-z~\\x80-\\xFF+";
 292+$wgIllegalFileChars = ":"; // These are additional characters that should be replaced with '-' in file names
292293
293294 /**
294295 * The external URL protocols
Index: trunk/phase3/includes/GlobalFunctions.php
@@ -3228,8 +3228,9 @@
32293229 * @param $name Mixed: filename to process
32303230 */
32313231 function wfStripIllegalFilenameChars( $name ) {
 3232+ global $wgIllegalFileChars;
32323233 $name = wfBaseName( $name );
3233 - $name = preg_replace ( "/[^".Title::legalChars()."]|:/", '-', $name );
 3234+ $name = preg_replace("/[^".Title::legalChars()."]".($wgIllegalFileChars ? "|[".$wgIllegalFileChars."]":"")."/",'-',$name);
32343235 return $name;
32353236 }
32363237

Status & tagging log