diff --git a/lib/Constants.php b/lib/Constants.php index 1726d7dc9..6a9e22455 100644 --- a/lib/Constants.php +++ b/lib/Constants.php @@ -175,6 +175,19 @@ class Constants { 'x-office/spreadsheet', ]; + public const FILENAME_INVALID_CHARS = [ + "\n", + '/', + '\\', + ':', + '*', + '?', + '"', + '<', + '>', + '|', + ]; + /** * !! Keep in sync with src/mixins/ShareTypes.js !! */ diff --git a/lib/Service/FormsService.php b/lib/Service/FormsService.php index 8683d7029..f95b60017 100644 --- a/lib/Service/FormsService.php +++ b/lib/Service/FormsService.php @@ -777,6 +777,6 @@ public function getTemporaryUploadedFilePath(Form $form, Question $question): st } private static function normalizeFileName(string $fileName): string { - return str_replace([...mb_str_split(\OCP\Constants::FILENAME_INVALID_CHARS), "\n"], '-', $fileName); + return trim(str_replace(Constants::FILENAME_INVALID_CHARS, '-', $fileName)); } }