From 1e769a5f9ad9601c1a4f00edc85b3619d9163256 Mon Sep 17 00:00:00 2001 From: Waldir Pimenta Date: Tue, 7 Aug 2012 20:09:26 +0100 Subject: [PATCH] improve wfStripIllegalFilenameChars()'s readability make the preg_replace regex more readable, and expand documentation a little. Change-Id: Id26d9d42be7d3f2780e82da27dd2477d62d8e106 --- includes/GlobalFunctions.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index e25ce26685..f83a31b6f3 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -3738,17 +3738,18 @@ function wfGenerateToken( $salt = '' ) { /** * Replace all invalid characters with - + * Additional characters can be defined in $wgIllegalFileChars (see bug 20489) + * By default, $wgIllegalFileChars = ':' * * @param $name Mixed: filename to process * @return String */ function wfStripIllegalFilenameChars( $name ) { global $wgIllegalFileChars; + $illegalFileChars = $wgIllegalFileChars ? "|[" . $wgIllegalFileChars . "]" : ''; $name = wfBaseName( $name ); $name = preg_replace( - "/[^" . Title::legalChars() . "]" . - ( $wgIllegalFileChars ? "|[" . $wgIllegalFileChars . "]" : '' ) . - "/", + "/[^" . Title::legalChars() . "]" . $illegalFileChars . "/", '-', $name ); -- 2.20.1