From 1567fb745d608cd21ac92f095398512334fa2613 Mon Sep 17 00:00:00 2001 From: shortcutme Date: Tue, 21 May 2019 15:52:44 +0200 Subject: [PATCH] Fix sidebar site download with utf8 title --- plugins/Sidebar/SidebarPlugin.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/Sidebar/SidebarPlugin.py b/plugins/Sidebar/SidebarPlugin.py index 5f6dd63e..5dcda6c9 100644 --- a/plugins/Sidebar/SidebarPlugin.py +++ b/plugins/Sidebar/SidebarPlugin.py @@ -6,6 +6,8 @@ import math import time import json import io +import urllib +import urllib.parse import gevent @@ -66,9 +68,10 @@ class UiRequestPlugin(object): if not site: 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")) - 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("."))