# HG changeset patch # User Goffi # Date 1483285112 -3600 # Node ID 5874da3811b77363067f44ecdcfc3dbd1114494d # Parent c96fe007ca410188f508ee60492a71348c02e466 plugin text syntaxes: log error on cleanXHTML failure diff -r c96fe007ca41 -r 5874da3811b7 src/plugins/plugin_misc_text_syntaxes.py --- a/src/plugins/plugin_misc_text_syntaxes.py Sun Dec 25 16:43:56 2016 +0100 +++ b/src/plugins/plugin_misc_text_syntaxes.py Sun Jan 01 16:38:32 2017 +0100 @@ -148,6 +148,10 @@ """ 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 @@ 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