# HG changeset patch # User Goffi # Date 1408561153 -7200 # Node ID f030491cff75115b828588b83cf480f6a89c2fce # Parent 88ece2a00c63b34764931008af119656cd0cdd88 browser side (XMLUI): fixed bad use of text instead of XHTML in dialogs diff -r 88ece2a00c63 -r f030491cff75 src/browser/sat_browser/html_tools.py --- a/src/browser/sat_browser/html_tools.py Thu Aug 14 13:27:07 2014 +0200 +++ b/src/browser/sat_browser/html_tools.py Wed Aug 20 20:59:13 2014 +0200 @@ -29,19 +29,20 @@ """Naive sanitization of HTML""" return html.replace('<', '<').replace('>', '>') - def html_strip(html): """Strip leading/trailing white spaces, HTML line breaks and   sequences.""" cleaned = re.sub(r"^(
| |\s)+", "", html) cleaned = re.sub(r"(
| |\s)+$", "", cleaned) return cleaned - def inlineRoot(xhtml): """ make root element inline """ doc = dom.parseString(xhtml) return xmltools.inlineRoot(doc) - def convertNewLinesToXHTML(text): return text.replace('\n', '
') + +def XHTML2Text(xhtml): + """Helper method to apply both html_sanitize and convertNewLinesToXHTML""" + return convertNewLinesToXHTML(html_sanitize(xhtml)) diff -r 88ece2a00c63 -r f030491cff75 src/browser/sat_browser/xmlui.py --- a/src/browser/sat_browser/xmlui.py Thu Aug 14 13:27:07 2014 +0200 +++ b/src/browser/sat_browser/xmlui.py Wed Aug 20 20:59:13 2014 +0200 @@ -20,8 +20,10 @@ from sat.core.log import getLogger log = getLogger(__name__) from sat_frontends.tools import xmlui +from sat_frontends.tools import strings from sat_browser.constants import Const as C from sat_browser import dialog +from sat_browser import html_tools from pyjamas.ui.VerticalPanel import VerticalPanel from pyjamas.ui.HorizontalPanel import HorizontalPanel @@ -309,6 +311,8 @@ def __init__(self, _xmlui_parent, title, message, level): #TODO: level is not managed + title = html_tools.html_sanitize(title) + message = strings.addURLToText(html_tools.XHTML2Text(message)) Dlg.__init__(self) xmlui.MessageDialog.__init__(self, _xmlui_parent) dialog.InfoDialog.__init__(self, title, message, self._xmluiValidated()) @@ -326,8 +330,9 @@ def __init__(self, _xmlui_parent, title, message, level): #TODO: level is not managed + title = html_tools.html_sanitize(title) + message = strings.addURLToText(html_tools.XHTML2Text(message)) xmlui.ConfirmDialog.__init__(self, _xmlui_parent) - print "self.parent = %s" % self._xmlui_parent Dlg.__init__(self) dialog.ConfirmDialog.__init__(self, self.answered, message, title)