Skip to content

Commit 56c1518

Browse files
Merge pull request #510 from lopatoid/master
Thanks to @lopatoid, make download function work with non-US-ASCII characters
2 parents a4aaa61 + d7522b1 commit 56c1518

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

remi/gui.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@
4444
unescape = html.unescape
4545

4646
from .server import runtimeInstances
47-
47+
try:
48+
from urllib.parse import quote
49+
except ImportError:
50+
from urllib import quote
4851

4952
log = logging.getLogger('remi.gui')
5053

@@ -4170,8 +4173,9 @@ def __init__(self, text, filename, path_separator='/', *args, **kwargs):
41704173
def download(self):
41714174
with open(self._filename, 'rb') as f:
41724175
content = f.read()
4176+
filename = quote(os.path.basename(self._filename))
41734177
headers = {'Content-type': 'application/octet-stream',
4174-
'Content-Disposition': 'attachment; filename="%s"' % os.path.basename(self._filename)}
4178+
'Content-Disposition': 'attachment; filename="{0}"; filename*=UTF-8\'\'{0}'.format(filename)}
41754179
return [content, headers]
41764180

41774181

0 commit comments

Comments
 (0)