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 uuid import uuid4
|
||||||
from markupsafe import escape, Markup # dependency of flask
|
from markupsafe import escape, Markup # dependency of flask
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
from lxml.etree import ParserError
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
# at least bleach 6.0 is needed -> incomplatible change from list arguments to set arguments
|
||||||
from bleach import clean_text as clean_html
|
from bleach import clean_text as clean_html
|
||||||
BLEACH = True
|
BLEACH = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -1001,10 +1003,14 @@ def edit_book_series_index(series_index, book):
|
||||||
def edit_book_comments(comments, book):
|
def edit_book_comments(comments, book):
|
||||||
modify_date = False
|
modify_date = False
|
||||||
if comments:
|
if comments:
|
||||||
if BLEACH:
|
try:
|
||||||
comments = clean_html(comments, tags=None, attributes=None)
|
if BLEACH:
|
||||||
else:
|
comments = clean_html(comments, tags=set(), attributes=set())
|
||||||
comments = clean_html(comments)
|
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 len(book.comments):
|
||||||
if book.comments[0].text != comments:
|
if book.comments[0].text != comments:
|
||||||
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':
|
elif s == 'date':
|
||||||
epub_metadata[s] = tmp[0][:10]
|
epub_metadata[s] = tmp[0][:10]
|
||||||
else:
|
else:
|
||||||
epub_metadata[s] = tmp[0]
|
epub_metadata[s] = tmp[0].strip()
|
||||||
else:
|
else:
|
||||||
epub_metadata[s] = 'Unknown'
|
epub_metadata[s] = 'Unknown'
|
||||||
|
|
||||||
|
|
|
@ -140,7 +140,7 @@ def convert_to_kobo_timestamp_string(timestamp):
|
||||||
# @download_required
|
# @download_required
|
||||||
def HandleSyncRequest():
|
def HandleSyncRequest():
|
||||||
if not current_user.role_download():
|
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)
|
return abort(403)
|
||||||
sync_token = SyncToken.SyncToken.from_headers(request.headers)
|
sync_token = SyncToken.SyncToken.from_headers(request.headers)
|
||||||
log.info("Kobo library sync request received")
|
log.info("Kobo library sync request received")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user