@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

authored by

Anh Nhan Nguyen and committed by
epriestley
e38b9934 c4e217e2

+13 -1
+13 -1
src/applications/files/storage/PhabricatorFile.php
··· 368 368 } 369 369 370 370 public static function normalizeFileName($file_name) { 371 - return preg_replace('/[^a-zA-Z0-9.~_-]/', '_', $file_name); 371 + $pattern = "@[\\x00-\\x19#%&+!~'\$\"\/=\\\\?<> ]+@"; 372 + $file_name = preg_replace($pattern, '_', $file_name); 373 + $file_name = preg_replace('@_+@', '_', $file_name); 374 + $file_name = trim($file_name, '_'); 375 + 376 + $disallowed_filenames = array( 377 + '.' => 'dot', 378 + '..' => 'dotdot', 379 + '' => 'file', 380 + ); 381 + $file_name = idx($disallowed_filenames, $file_name, $file_name); 382 + 383 + return $file_name; 372 384 } 373 385 374 386 public function delete() {