Fix sidebar site download with utf8 title

This commit is contained in:
shortcutme 2019-05-21 15:52:44 +02:00
parent 416f563261
commit 1567fb745d
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE

View file

@ -6,6 +6,8 @@ import math
import time import time
import json import json
import io import io
import urllib
import urllib.parse
import gevent import gevent
@ -66,9 +68,10 @@ class UiRequestPlugin(object):
if not site: if not site:
return self.error404("Site not found") return self.error404("Site not found")
title = site.content_manager.contents.get("content.json", {}).get("title", "").encode('ascii', 'ignore') title = site.content_manager.contents.get("content.json", {}).get("title", "")
filename = "%s-backup-%s.zip" % (title, time.strftime("%Y-%m-%d_%H_%M")) filename = "%s-backup-%s.zip" % (title, time.strftime("%Y-%m-%d_%H_%M"))
self.sendHeader(content_type="application/zip", extra_headers={'Content-Disposition': 'attachment; filename="%s"' % filename}) filename_quoted = urllib.parse.quote(filename)
self.sendHeader(content_type="application/zip", extra_headers={'Content-Disposition': 'attachment; filename="%s"' % filename_quoted})
return self.streamZip(site.storage.getPath(".")) return self.streamZip(site.storage.getPath("."))