1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

Fixed #23759 -- Preserved all file extensions in Storage.get_available_name().

This commit is contained in:
Adam Zapletal
2024-02-18 21:56:26 -06:00
committed by Mariusz Felisiak
parent 3426a5c33c
commit eb2d49b734
3 changed files with 21 additions and 13 deletions

View File

@@ -69,7 +69,8 @@ class Storage:
"Detected path traversal attempt in '%s'" % dir_name
)
validate_file_name(file_name)
file_root, file_ext = os.path.splitext(file_name)
file_ext = "".join(pathlib.PurePath(file_name).suffixes)
file_root = file_name.removesuffix(file_ext)
# If the filename already exists, generate an alternative filename
# until it doesn't exist.
# Truncate original name if required, so the new filename does not