From 26438f97ab54700136dadda558b014318e073426 Mon Sep 17 00:00:00 2001 From: OzzieIsaacs Date: Mon, 6 Mar 2017 19:19:14 +0100 Subject: [PATCH] Bugfix Filename without unidecode dependency --- cps/helper.py | 2 +- cps/web.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cps/helper.py b/cps/helper.py index 54fa1946..86e6cfd9 100755 --- a/cps/helper.py +++ b/cps/helper.py @@ -238,7 +238,7 @@ def get_valid_filename(value, replace_whitespace=True): value=value.replace(u'§',u'SS') value=value.replace(u'ß',u'ss') value = unicodedata.normalize('NFKD', value) - re_slugify = re.compile('[\W\s-]', re.UNICODE) + re_slugify = re.compile('[^\w\s-]', re.UNICODE) value = unicode(re_slugify.sub('', value).strip()) if replace_whitespace: #*+:\"/<>? werden durch _ ersetzt diff --git a/cps/web.py b/cps/web.py index d4992658..c242879d 100755 --- a/cps/web.py +++ b/cps/web.py @@ -675,7 +675,7 @@ def get_opds_download_link(book_id, format): file_name = book.authors[0].name + '-' + file_name file_name = helper.get_valid_filename(file_name) response = make_response(send_from_directory(os.path.join(config.config_calibre_dir, book.path), data.name + "." + format)) - response.headers["Content-Disposition"] = "attachment; filename=\"%s.%s\"" % (urllib.quote(file_name.encode('utf8')), format) + response.headers["Content-Disposition"] = "attachment; filename*=UTF-8''%s.%s" % (urllib.quote(file_name.encode('utf8')), format) return response @@ -1283,7 +1283,7 @@ def get_download_link(book_id, format): response.headers["Content-Type"] = mimetypes.types_map['.' + format] except: pass - response.headers["Content-Disposition"] = "attachment; filename=\"%s.%s\"" % (urllib.quote(file_name.encode('utf-8')), format) + response.headers["Content-Disposition"] = "attachment; filename*=UTF-8''%s.%s" % (urllib.quote(file_name.encode('utf-8')), format) return response else: abort(404)