mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-20 13:52:40 +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:
parent
c4e217e204
commit
e38b993408
1 changed files with 13 additions and 1 deletions
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue