use utf8 name too for file downloading

This commit is contained in:
Kcchouette 2021-01-02 00:56:53 +01:00 committed by Saptak S
parent c5308efc57
commit 89043b8545
No known key found for this signature in database
GPG Key ID: 2D9B32E54C68A3FB

View File

@ -25,6 +25,7 @@ import mimetypes
import gzip
from flask import Response, request, render_template, make_response
from unidecode import unidecode
from werkzeug.urls import url_quote
class SendBaseModeWeb:
@ -263,7 +264,11 @@ class SendBaseModeWeb:
if use_gzip:
r.headers.set("Content-Encoding", "gzip")
r.headers.set("Content-Length", filesize)
r.headers.set("Content-Disposition", "inline", filename=unidecode(basename))
filename_dict = {
'filename': unidecode(basename),
'filename*': "UTF-8''%s" % url_quote(basename)
}
r.headers.set("Content-Disposition", "inline", **filename_dict)
r = self.web.add_security_headers(r)
(content_type, _) = mimetypes.guess_type(basename, strict=False)
if content_type is not None: