Skip to content

Commit

Permalink
fix: Improve compatibility with Windows for uploaded files
Browse files Browse the repository at this point in the history
Signed-off-by: Kostiantyn Miakshyn <[email protected]>
  • Loading branch information
Koc committed Jan 23, 2025
1 parent 04bea4c commit 556303e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/Service/FormsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,19 @@
* @psalm-import-type FormsShare from ResponseDefinitions
*/
class FormsService {
private const FILENAME_INVALID_CHARS = [
"\n",
'/',
'\\',
':',
'*',
'?',
'"',
'<',
'>',
'|',
];

private ?IUser $currentUser;

public function __construct(
Expand Down Expand Up @@ -785,6 +798,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(self::FILENAME_INVALID_CHARS, '-', $fileName));
}
}

0 comments on commit 556303e

Please sign in to comment.