mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 14:32:22 -04:00
Fix images with non-Latin text and commas failing to display
Flask's .send_file() method sends a content-disposition header based on the filename. If the filename includes non-Latin text, it adds an rfc5987 unicode filename, but does not percent-escape the commas. This causes Chromium to fail to load the image with the following error: net::ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION curl -v http://127.0.0.1:40000/Captura%20de%20ecr%C3%A3%202023-02-26,%20%C3%A0s%2018.33.03.png * Trying 127.0.0.1:40000... * Connected to 127.0.0.1 (127.0.0.1) port 40000 (#0) > GET /Captura%20de%20ecr%C3%A3%202023-02-26,%20%C3%A0s%2018.33.03.png HTTP/1.1 > Host: 127.0.0.1:40000 > User-Agent: curl/7.86.0 > Accept: */* > * Mark bundle as not supporting multiuse < HTTP/1.1 200 OK < Access-Control-Allow-Origin: * < Cache-Control: public, max-age=3600 < Content-Disposition: inline; filename="Captura de ecra 2023-02-26, as 18.33.03.png"; filename*=UTF-8''Captura%20de%20ecr%C3%A3%202023-02-26,%20%C3%A0s%2018.33.03.png Fixed by supplying a dummy filename.
This commit is contained in:
parent
03b05b6a06
commit
af620186ff
1 changed files with 1 additions and 1 deletions
|
@ -186,7 +186,7 @@ def _handle_local_file_request(request: LocalFileRequest) -> Response:
|
|||
else:
|
||||
max_age = 60 * 60
|
||||
return flask.send_file(
|
||||
fullpath, mimetype=mimetype, conditional=True, max_age=max_age # type: ignore[call-arg]
|
||||
fullpath, mimetype=mimetype, conditional=True, max_age=max_age, download_name="foo" # type: ignore[call-arg]
|
||||
)
|
||||
else:
|
||||
print(f"Not found: {path}")
|
||||
|
|
Loading…
Reference in a new issue