fix(file): Remove illegal chars in file_name

- / and \ cannot work as file names
- % is not allowed verbatim in URLs
- ? and # are not allowed because confused with query/hash separators
This commit is contained in:
Corentin Forler 2024-09-16 13:43:37 +02:00
parent 6b7c0007fe
commit 772df163cf
No known key found for this signature in database

View file

@ -675,7 +675,7 @@ class File(Document):
return self.save_file_on_filesystem()
def save_file_on_filesystem(self):
safe_file_name = self.file_name.replace("%", "_")
safe_file_name = re.sub(r"[/\\%?#]", "_", self.file_name)
if self.is_private:
self.file_url = f"/private/files/{safe_file_name}"
else: