Page MenuHomePhabricator

Configure illegal file characters
Closed, ResolvedPublic

Description

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:

Details

Reference
bz20489

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:52 PM
bzimport set Reference to bz20489.
Jdpond created this task.Sep 3 2009, 4:05 PM

Patch applied with r55802 by jdpond.

Gilles moved this task from Untriaged to Done on the Multimedia board.Dec 4 2014, 10:49 AM