Fix for #2961 (empty comment with newline causes error 500 on upload)
Language of error message for kobo sync improved
This commit is contained in:
parent
00acd745f4
commit
977f07364b
|
@ -27,8 +27,10 @@ from shutil import copyfile
|
|||
from uuid import uuid4
|
||||
from markupsafe import escape, Markup # dependency of flask
|
||||
from functools import wraps
|
||||
from lxml.etree import ParserError
|
||||
|
||||
try:
|
||||
# at least bleach 6.0 is needed -> incomplatible change from list arguments to set arguments
|
||||
from bleach import clean_text as clean_html
|
||||
BLEACH = True
|
||||
except ImportError:
|
||||
|
@ -1001,10 +1003,14 @@ def edit_book_series_index(series_index, book):
|
|||
def edit_book_comments(comments, book):
|
||||
modify_date = False
|
||||
if comments:
|
||||
if BLEACH:
|
||||
comments = clean_html(comments, tags=None, attributes=None)
|
||||
else:
|
||||
comments = clean_html(comments)
|
||||
try:
|
||||
if BLEACH:
|
||||
comments = clean_html(comments, tags=set(), attributes=set())
|
||||
else:
|
||||
comments = clean_html(comments)
|
||||
except ParserError as e:
|
||||
log.error("Comments of book {} are corrupted: {}".format(book.id, e))
|
||||
comments = ""
|
||||
if len(book.comments):
|
||||
if book.comments[0].text != comments:
|
||||
book.comments[0].text = comments
|
||||
|
|
|
@ -102,7 +102,7 @@ def get_epub_info(tmp_file_path, original_file_name, original_file_extension):
|
|||
elif s == 'date':
|
||||
epub_metadata[s] = tmp[0][:10]
|
||||
else:
|
||||
epub_metadata[s] = tmp[0]
|
||||
epub_metadata[s] = tmp[0].strip()
|
||||
else:
|
||||
epub_metadata[s] = 'Unknown'
|
||||
|
||||
|
|
|
@ -140,7 +140,7 @@ def convert_to_kobo_timestamp_string(timestamp):
|
|||
# @download_required
|
||||
def HandleSyncRequest():
|
||||
if not current_user.role_download():
|
||||
log.info("User needs download permissions for syncing library with Kobo")
|
||||
log.info("Users need download permissions for syncing library to Kobo reader")
|
||||
return abort(403)
|
||||
sync_token = SyncToken.SyncToken.from_headers(request.headers)
|
||||
log.info("Kobo library sync request received")
|
||||
|
|
Loading…
Reference in New Issue
Block a user