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 29, 2025
1 parent 862f39e commit 3859656
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 14 additions & 1 deletion lib/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Constants {
'submissionId' => '\d+',
'path' => '.+'
];

/**
* Used AppConfig Keys
*/
Expand Down Expand Up @@ -169,6 +169,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 3859656

Please sign in to comment.