mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-05-02 13:22:32 +08:00
Address review: include disposition type and ASCII fallback
- Add 'inline' disposition token per RFC 2183 - Include both filename="ascii" and filename*=utf-8'' for max compatibility - Create ASCII-safe fallback replacing non-printable chars with _
This commit is contained in:
parent
b00db6fad0
commit
40c61a257d
17
server.py
17
server.py
@ -54,7 +54,7 @@ if args.enable_manager:
|
||||
import comfyui_manager
|
||||
|
||||
|
||||
def _make_content_disposition(filename: str) -> str:
|
||||
def _make_content_disposition(filename: str, disposition: str = "inline") -> str:
|
||||
"""
|
||||
Generate RFC 8187 compliant Content-Disposition header.
|
||||
|
||||
@ -63,13 +63,20 @@ def _make_content_disposition(filename: str) -> str:
|
||||
characters or needs special encoding.
|
||||
|
||||
Examples:
|
||||
ASCII: filename="test.png"
|
||||
Unicode: filename*=utf-8''%E6%B5%8B%E8%AF%95.png
|
||||
ASCII: inline; filename="test.png"; filename*=UTF-8''test.png
|
||||
Unicode: inline; filename="__.png"; filename*=UTF-8''%E6%B5%8B%E8%AF%95.png
|
||||
"""
|
||||
import urllib.parse
|
||||
# Always use RFC 8187 extended notation for maximum compatibility
|
||||
|
||||
# Create ASCII-safe fallback filename
|
||||
fallback = "".join(
|
||||
ch if 0x20 <= ord(ch) < 0x7F and ch not in {'"', '\\'} else "_"
|
||||
for ch in filename
|
||||
) or "download"
|
||||
|
||||
# Percent-encode the UTF-8 filename
|
||||
encoded_filename = urllib.parse.quote(filename, safe='')
|
||||
return f"filename*=utf-8''{encoded_filename}"
|
||||
return f"{disposition}; filename=\"{fallback}\"; filename*=UTF-8''{encoded_filename}"
|
||||
|
||||
|
||||
def _remove_sensitive_from_queue(queue: list) -> list:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user