changeset 5175:18b0e4d1ae58

helpers: make desc_stylize work when given html escaped strings The function returns strings with html markup. The result can thus not be escaped and we must assume that the input already has been escaped. That may or may not the case yet.
author Mads Kiilerich <madski@unity3d.com>
date Tue, 09 Jun 2015 22:50:20 +0200
parents 65872885d876
children c417ef1f43b1
files kallithea/lib/helpers.py kallithea/tests/other/test_libs.py
diffstat 2 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/lib/helpers.py	Tue Jun 09 22:46:40 2015 +0200
+++ b/kallithea/lib/helpers.py	Tue Jun 09 22:50:20 2015 +0200
@@ -545,13 +545,13 @@
     if not value:
         return ''
 
-    value = re.sub(r'\[see\ \=\>\ *([a-zA-Z0-9\/\=\?\&\ \:\/\.\-]*)\]',
+    value = re.sub(r'\[see\ \=&gt;\ *([a-zA-Z0-9\/\=\?\&\ \:\/\.\-]*)\]',
                    '<div class="metatag" tag="see">see =&gt; \\1 </div>', value)
-    value = re.sub(r'\[license\ \=\>\ *([a-zA-Z0-9\/\=\?\&\ \:\/\.\-]*)\]',
+    value = re.sub(r'\[license\ \=&gt;\ *([a-zA-Z0-9\/\=\?\&\ \:\/\.\-]*)\]',
                    '<div class="metatag" tag="license"><a href="http:\/\/www.opensource.org/licenses/\\1">\\1</a></div>', value)
-    value = re.sub(r'\[(requires|recommends|conflicts|base)\ \=\>\ *([a-zA-Z0-9\-\/]*)\]',
+    value = re.sub(r'\[(requires|recommends|conflicts|base)\ \=&gt;\ *([a-zA-Z0-9\-\/]*)\]',
                    '<div class="metatag" tag="\\1">\\1 =&gt; <a href="/\\2">\\2</a></div>', value)
-    value = re.sub(r'\[(lang|language)\ \=\>\ *([a-zA-Z\-\/\#\+]*)\]',
+    value = re.sub(r'\[(lang|language)\ \=&gt;\ *([a-zA-Z\-\/\#\+]*)\]',
                    '<div class="metatag" tag="lang">\\2</div>', value)
     value = re.sub(r'\[([a-z]+)\]',
                   '<div class="metatag" tag="\\1">\\1</div>', value)
--- a/kallithea/tests/other/test_libs.py	Tue Jun 09 22:46:40 2015 +0200
+++ b/kallithea/tests/other/test_libs.py	Tue Jun 09 22:50:20 2015 +0200
@@ -189,8 +189,8 @@
             "[requires => url] [lang => python] [just a tag]"
             "[,d] [ => ULR ] [obsolete] [desc]]"
         )
-        from kallithea.lib.helpers import desc_stylize
-        res = desc_stylize(sample)
+        from kallithea.lib.helpers import desc_stylize, html_escape
+        res = desc_stylize(html_escape(sample))
         self.assertTrue('<div class="metatag" tag="tag">tag</div>' in res)
         self.assertTrue('<div class="metatag" tag="obsolete">obsolete</div>' in res)
         self.assertTrue('<div class="metatag" tag="stale">stale</div>' in res)