mirror of
https://github.com/janeczku/calibre-web
synced 2025-10-24 11:57:40 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user