plugin text syntaxes: log error on cleanXHTML failure
This commit is contained in:
parent
a37b57e7ad
commit
46ced6d74e
1 changed files with 7 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue