url encode filename
All checks were successful
Build and Publish / build-release (push) Successful in 48s
All checks were successful
Build and Publish / build-release (push) Successful in 48s
This commit is contained in:
@@ -58,9 +58,6 @@ def document_s3_key(org_id: str, document_id: str, filename: str) -> str:
|
|||||||
return f"{s3_path_prefix(org_id, document_id)}{filename}"
|
return f"{s3_path_prefix(org_id, document_id)}{filename}"
|
||||||
|
|
||||||
def sanitize_filename(filename: str) -> str:
|
def sanitize_filename(filename: str) -> str:
|
||||||
"""Sanitize filename for S3"""
|
"""URL encode filename for S3"""
|
||||||
# Remove path separators and special characters
|
from urllib.parse import quote
|
||||||
filename = filename.replace("/", "_").replace("\\", "_")
|
return quote(filename, safe="")
|
||||||
# Keep only safe characters
|
|
||||||
safe_chars = set("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_")
|
|
||||||
return "".join(c for c in filename if c in safe_chars)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user