}
/**
- * Replace all invalid characters with -
- * Additional characters can be defined in $wgIllegalFileChars (see bug 20489)
- * By default, $wgIllegalFileChars = ':'
+ * Replace all invalid characters with '-'.
+ * Additional characters can be defined in $wgIllegalFileChars (see T22489).
+ * By default, $wgIllegalFileChars includes ':', '/', '\'.
*
* @param string $name Filename to process
* @return string
function wfStripIllegalFilenameChars( $name ) {
global $wgIllegalFileChars;
$illegalFileChars = $wgIllegalFileChars ? "|[" . $wgIllegalFileChars . "]" : '';
- $name = wfBaseName( $name );
$name = preg_replace(
"/[^" . Title::legalChars() . "]" . $illegalFileChars . "/",
'-',
$name
);
+ // $wgIllegalFileChars may not include '/' and '\', so we still need to do this
+ $name = wfBaseName( $name );
return $name;
}