Configurable Illegal Chars in File names
Sometime between 1.11 and 1.13, the function wfStripIllegalFilenameChars in Global.php was modified to change all occurances of ':' to '-' by adding the '|:' to the preg_replace.
This addition effectively disables the ability to use categories or namespaces as part of the file definition. One specific case is the use of namespace for restricting access to images/files:
[[File:Project:ProjectPlan.txt]]
Additionally, since it is hardcoded, it does not allow certain platforms to further restrict characters in the file names, for example, while backtick "`" is certainly allowable, on certain platforms if used in a filename will cause issues.
Furthermore, these types of things are generally configurable in MediaWiki for example:
$wgLegalTitleChars = " %!\"$&'()*,\\-.\\/0-9:;=?@A-Z\\\\^_`a-z~\\x80-\\xFF+";
Which is used in Title::legalChars() as
public static function legalChars() {
global $wgLegalTitleChars; return $wgLegalTitleChars;
}
The proposed change is to make illegal file characters a configuration variable, defaulting to the current ":", e.g.
$wgIllegalFileChars = ":"; // These are additional characters that should be replaced with '-' in file names
The change is simple, straightforward, and would have minimal performance impact - see attachments. It's value would be to allow both cross-platform capabilities and FileRepo configurability, as well as enable [[Extension:NSFileRepo]] without requiring patches.
Version: 1.16.x
Severity: normal
Attached: