diff --git a/lib/Constants.php b/lib/Constants.php index fbca3d900..4b00ceb84 100644 --- a/lib/Constants.php +++ b/lib/Constants.php @@ -23,7 +23,7 @@ class Constants { 'submissionId' => '\d+', 'path' => '.+' ]; - + /** * Used AppConfig Keys */ @@ -169,6 +169,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 e07664009..a4f1399da 100644 --- a/lib/Service/FormsService.php +++ b/lib/Service/FormsService.php @@ -785,6 +785,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)); } }