Mercurial > libervia-backend
changeset 2106:5874da3811b7
plugin text syntaxes: log error on cleanXHTML failure
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 01 Jan 2017 16:38:32 +0100 |
parents | c96fe007ca41 |
children | 2c31ddf633e5 |
files | src/plugins/plugin_misc_text_syntaxes.py |
diffstat | 1 files changed, 7 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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