From: Waldir Pimenta Date: Tue, 7 Aug 2012 19:09:26 +0000 (+0100) Subject: improve wfStripIllegalFilenameChars()'s readability X-Git-Tag: 1.31.0-rc.0~22817 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dmembres/cotisations/gestion/rappel_supprimer.php?a=commitdiff_plain;h=1e769a5f9ad9601c1a4f00edc85b3619d9163256;p=lhc%2Fweb%2Fwiklou.git improve wfStripIllegalFilenameChars()'s readability make the preg_replace regex more readable, and expand documentation a little. Change-Id: Id26d9d42be7d3f2780e82da27dd2477d62d8e106 --- 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 );