From 46ced6d74e8829660842d2b200c0687091811aac Mon Sep 17 00:00:00 2001 From: Goffi Date: Sun, 1 Jan 2017 16:38:32 +0100 Subject: [PATCH] plugin text syntaxes: log error on cleanXHTML failure --- src/plugins/plugin_misc_text_syntaxes.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/plugins/plugin_misc_text_syntaxes.py b/src/plugins/plugin_misc_text_syntaxes.py index 3e94b462..1fa34fd6 100755 --- a/src/plugins/plugin_misc_text_syntaxes.py +++ b/src/plugins/plugin_misc_text_syntaxes.py @@ -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