From ad54e0bcf8ab6b20111aab9889c6dd2cfe5d7111 Mon Sep 17 00:00:00 2001 From: "Jack D. Pond" Date: Fri, 4 Sep 2009 03:44:14 +0000 Subject: [PATCH] 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 "-". --- includes/DefaultSettings.php | 1 + includes/GlobalFunctions.php | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index a696564221..d0b806f63d 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -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 diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index e1eb6abd85..4cbed9e5a7 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -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; } -- 2.20.1