diff rhodecode/lib/helpers.py @ 2427:f467c75544af beta

Added h.tooltip to all places that tooltip_title is used. - improved escaping of < and > inside tooltips
author Marcin Kuzminski <marcin@python-works.com>
date Fri, 08 Jun 2012 21:54:50 +0200
parents 44f328d6f209
children 9f37281195a2 9b623dcddb02
line wrap: on
line diff
--- a/rhodecode/lib/helpers.py	Fri Jun 08 02:50:47 2012 +0200
+++ b/rhodecode/lib/helpers.py	Fri Jun 08 21:54:50 2012 +0200
@@ -108,7 +108,7 @@
 
     def __call__(self, field_name, form_errors):
         tmpl = """<span class="error_msg">%s</span>"""
-        if form_errors and form_errors.has_key(field_name):
+        if form_errors and field_name in form_errors:
             return literal(tmpl % form_errors.get(field_name))
 
 get_error = _GetError()
@@ -117,12 +117,15 @@
 class _ToolTip(object):
 
     def __call__(self, tooltip_title, trim_at=50):
-        """Special function just to wrap our text into nice formatted
+        """
+        Special function just to wrap our text into nice formatted
         autowrapped text
 
         :param tooltip_title:
         """
-        return escape(tooltip_title)
+        tooltip_title = escape(tooltip_title)
+        tooltip_title = tooltip_title.replace('<', '&lt;').replace('>', '&gt;')
+        return tooltip_title
 tooltip = _ToolTip()
 
 
@@ -349,7 +352,7 @@
     if date:
         return (date.strftime(_(u"%a, %d %b %Y %H:%M:%S").encode('utf8'))
             .decode('utf8'))
-    
+
     return ""