mirror of
https://github.com/lucaspalomodevelop/indico-plugins.git
synced 2026-03-14 16:04:36 +00:00
It was in the indico core because flask did not expose it and we needed it there, but that's no longer the case (still not exposed though) so we include it here now.
23 lines
732 B
Python
23 lines
732 B
Python
# This file is part of the Indico plugins.
|
|
# Copyright (C) 2002 - 2021 CERN
|
|
#
|
|
# The Indico plugins are free software; you can redistribute
|
|
# them and/or modify them under the terms of the MIT License;
|
|
# see the LICENSE file for more details.
|
|
|
|
import unicodedata
|
|
|
|
from werkzeug.urls import url_quote
|
|
|
|
|
|
def make_content_disposition_args(attachment_filename):
|
|
try:
|
|
attachment_filename = attachment_filename.encode('ascii')
|
|
except UnicodeEncodeError:
|
|
return {
|
|
'filename': unicodedata.normalize('NFKD', attachment_filename).encode('ascii', 'ignore'),
|
|
'filename*': "UTF-8''%s" % url_quote(attachment_filename, safe=b''),
|
|
}
|
|
else:
|
|
return {'filename': attachment_filename}
|