Skip to content

Commit

Permalink
make download function work with non-US-ASCII characters
Browse files Browse the repository at this point in the history
  • Loading branch information
lopatoid committed Feb 21, 2023
1 parent c6a61da commit 6c9bc9f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions remi/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
unescape = html.unescape

from .server import runtimeInstances

import urllib.parse

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

Expand Down Expand Up @@ -4136,8 +4136,9 @@ def __init__(self, text, filename, path_separator='/', *args, **kwargs):
def download(self):
with open(self._filename, 'r+b') as f:
content = f.read()
filename = urllib.parse.quote(os.path.basename(self._filename))
headers = {'Content-type': 'application/octet-stream',
'Content-Disposition': 'attachment; filename="%s"' % os.path.basename(self._filename)}
'Content-Disposition': f'attachment; filename="{filename}"; filename*=UTF-8\'\'{filename}'}
return [content, headers]


Expand Down

0 comments on commit 6c9bc9f

Please sign in to comment.