mirror of
https://github.com/janeczku/calibre-web
synced 2024-11-30 21:40:00 +00:00
Fix download error when book title contains non-latin characters (e.g. Chinese)
This commit is contained in:
parent
f163ef2202
commit
17622c1fbf
18
cps/web.py
18
cps/web.py
@ -212,7 +212,14 @@ def get_opds_download_link(book_id, format):
|
|||||||
file_name = author+'-'+file_name
|
file_name = author+'-'+file_name
|
||||||
file_name = helper.get_valid_filename(file_name)
|
file_name = helper.get_valid_filename(file_name)
|
||||||
response = make_response(send_from_directory(os.path.join(config.DB_ROOT, book.path), data.name + "." +format))
|
response = make_response(send_from_directory(os.path.join(config.DB_ROOT, book.path), data.name + "." +format))
|
||||||
response.headers["Content-Disposition"] = "attachment; filename=%s.%s" % (file_name, format)
|
#response.headers["Content-Disposition"] = "attachment; filename=%s.%s" % (data.name, format)
|
||||||
|
response.headers["Content-Disposition"] = \
|
||||||
|
"attachment; " \
|
||||||
|
"filename={utf_filename}.{suffix};" \
|
||||||
|
"filename*=UTF-8''{utf_filename}.{suffix}".format(
|
||||||
|
utf_filename=file_name.encode('utf-8'),
|
||||||
|
suffix=format
|
||||||
|
)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
@app.route("/", defaults={'page': 1})
|
@app.route("/", defaults={'page': 1})
|
||||||
@ -363,7 +370,14 @@ def get_download_link(book_id, format):
|
|||||||
file_name = author+'-'+file_name
|
file_name = author+'-'+file_name
|
||||||
file_name = helper.get_valid_filename(file_name)
|
file_name = helper.get_valid_filename(file_name)
|
||||||
response = make_response(send_from_directory(os.path.join(config.DB_ROOT, book.path), data.name + "." +format))
|
response = make_response(send_from_directory(os.path.join(config.DB_ROOT, book.path), data.name + "." +format))
|
||||||
response.headers["Content-Disposition"] = "attachment; filename=%s.%s" % (file_name, format)
|
#response.headers["Content-Disposition"] = "attachment; filename=%s.%s" % (file_name, format)
|
||||||
|
response.headers["Content-Disposition"] = \
|
||||||
|
"attachment; " \
|
||||||
|
"filename={utf_filename}.{suffix};" \
|
||||||
|
"filename*=UTF-8''{utf_filename}.{suffix}".format(
|
||||||
|
utf_filename=file_name.encode('utf-8'),
|
||||||
|
suffix=format
|
||||||
|
)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
@app.route('/register', methods = ['GET', 'POST'])
|
@app.route('/register', methods = ['GET', 'POST'])
|
||||||
|
Loading…
Reference in New Issue
Block a user