Skip to content

Commit f17fc99

Browse files
committed
fix: Improve compatibility with Windows for uploaded files
Signed-off-by: Kostiantyn Miakshyn <[email protected]>
1 parent 3491fd0 commit f17fc99

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/Constants.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,19 @@ class Constants {
175175
'x-office/spreadsheet',
176176
];
177177

178+
public const FILENAME_INVALID_CHARS = [
179+
"\n",
180+
'/',
181+
'\\',
182+
':',
183+
'*',
184+
'?',
185+
'"',
186+
'<',
187+
'>',
188+
'|',
189+
];
190+
178191
/**
179192
* !! Keep in sync with src/mixins/ShareTypes.js !!
180193
*/

lib/Service/FormsService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,6 @@ public function getTemporaryUploadedFilePath(Form $form, Question $question): st
777777
}
778778

779779
private static function normalizeFileName(string $fileName): string {
780-
return str_replace([...mb_str_split(\OCP\Constants::FILENAME_INVALID_CHARS), "\n"], '-', $fileName);
780+
return trim(str_replace(Constants::FILENAME_INVALID_CHARS, '-', $fileName));
781781
}
782782
}

0 commit comments

Comments
 (0)