1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-30 01:10:58 +01:00

Allow more characters in a file name

Summary:
Refs T1692 - Borrows from D5192, means suffers from the same problems, too (RTL markers and some more)

Extended the list hidden characters though, some characters of which I thought could confuse other parts of Phabricator

Test Plan:
uploaded some files with a suspicious name of ##[[ .,-#'*`hey`?#+~!"$%&?汉字漢字 seig##

Came out as `[[_.,-_*_hey_汉字漢字_seig`

Looks reasonable enough for me

Reviewers: epriestley, btrahan

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T1692

Differential Revision: https://secure.phabricator.com/D5413
This commit is contained in:
Anh Nhan Nguyen 2013-03-22 10:51:20 -07:00 committed by epriestley
parent c4e217e204
commit e38b993408

View file

@ -368,7 +368,19 @@ final class PhabricatorFile extends PhabricatorFileDAO
}
public static function normalizeFileName($file_name) {
return preg_replace('/[^a-zA-Z0-9.~_-]/', '_', $file_name);
$pattern = "@[\\x00-\\x19#%&+!~'\$\"\/=\\\\?<> ]+@";
$file_name = preg_replace($pattern, '_', $file_name);
$file_name = preg_replace('@_+@', '_', $file_name);
$file_name = trim($file_name, '_');
$disallowed_filenames = array(
'.' => 'dot',
'..' => 'dotdot',
'' => 'file',
);
$file_name = idx($disallowed_filenames, $file_name, $file_name);
return $file_name;
}
public function delete() {