Force .pdf extension on uploaded files regardless of user input
The file content is already validated as PDF, so the user-supplied extension should not be trusted or written to disk.
This commit is contained in:
parent
c28f734e71
commit
8856daf3c9
1 changed files with 1 additions and 1 deletions
|
|
@ -32,7 +32,7 @@ async def upload(filename: str, content_type: str, file_content: bytes) -> Docum
|
|||
|
||||
os.makedirs(UPLOAD_DIR, exist_ok=True)
|
||||
|
||||
ext = os.path.splitext(filename)[1] or ".pdf"
|
||||
ext = ".pdf" # Content already validated as PDF
|
||||
safe_name = f"{uuid.uuid4()}{ext}"
|
||||
file_path = os.path.join(UPLOAD_DIR, safe_name)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue