mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-08-09 03:42:13 -04:00
Allow non-ascii filenames for attachments
This commit is contained in:
parent
efdaa5dd55
commit
e85c7873dc
3 changed files with 17 additions and 8 deletions
|
@ -33,6 +33,7 @@ import os
|
|||
|
||||
import cgi
|
||||
import logging
|
||||
import urllib
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -181,10 +182,18 @@ class BaseMediaResource(Resource):
|
|||
if os.path.isfile(file_path):
|
||||
request.setHeader(b"Content-Type", media_type.encode("UTF-8"))
|
||||
if upload_name:
|
||||
request.setHeader(
|
||||
b"Content-Disposition",
|
||||
b"inline; filename=%s" % (upload_name.encode("utf-8"),),
|
||||
)
|
||||
if is_ascii(upload_name):
|
||||
request.setHeader(
|
||||
b"Content-Disposition",
|
||||
b"inline; filename=%s" % (upload_name.encode("utf-8"),),
|
||||
)
|
||||
else:
|
||||
request.setHeader(
|
||||
b"Content-Disposition",
|
||||
b"inline; filename*=utf-8''%s" % (
|
||||
urllib.quote(upload_name.encode("utf-8")),
|
||||
),
|
||||
)
|
||||
|
||||
# cache for at least a day.
|
||||
# XXX: we might want to turn this off for data we don't want to
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue