From 772df163cfa581565401f33a6d2563e49c848ae8 Mon Sep 17 00:00:00 2001 From: Corentin Forler Date: Mon, 16 Sep 2024 13:43:37 +0200 Subject: [PATCH] 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 --- frappe/core/doctype/file/file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/core/doctype/file/file.py b/frappe/core/doctype/file/file.py index e2c8228ae2..56492790dd 100755 --- a/frappe/core/doctype/file/file.py +++ b/frappe/core/doctype/file/file.py @@ -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: