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 Feb 19, 2025
1 parent 332dd9e commit 1c1d65e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions lib/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,19 @@ class Constants {
'x-office/spreadsheet',
];

public const FILENAME_INVALID_CHARS = [
"\n",
'/',
'\\',
':',
'*',
'?',
'"',
'<',
'>',
'|',
];

/**
* !! Keep in sync with src/mixins/ShareTypes.js !!
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/FormsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

0 comments on commit 1c1d65e

Please sign in to comment.