plugin text syntaxes: log error on cleanXHTML failure

This commit is contained in:
Goffi 2017-01-01 16:38:32 +01:00
commit 46ced6d74e

View file

@ -148,6 +148,10 @@ class TextSyntaxes(object):
"""
return self.host.memory.getParamA(NAME, CATEGORY , profile_key=profile)
def _logError(self, failure, action=u"converting syntax"):
log.error(u"Error while {action}: {failure}".format(action=action, failure=failure))
return failure
def cleanXHTML(self, xhtml):
""" Clean XHTML text by removing potentially dangerous/malicious parts
@param xhtml: raw xhtml text to clean (or lxml's HtmlElement)
@ -191,7 +195,9 @@ class TextSyntaxes(object):
elt.set("style", clean_style(elt.get('style')))
return html.tostring(xhtml_elt, encoding=unicode, method='xml')
return deferToThread(blocking_cleaning, xhtml)
d = deferToThread(blocking_cleaning, xhtml)
d.addErrback(self._logError, action=u"cleaning syntax")
return d
def convert(self, text, syntax_from, syntax_to=_SYNTAX_XHTML, safe=True, profile=None):
"""Convert a text between two syntaxes