# HG changeset patch # User Mads Kiilerich # Date 1433883020 -7200 # Node ID 18b0e4d1ae589e4207ea119d97132c587430b33c # Parent 65872885d876de95f34761a0c4929e894b87265c 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. diff -r 65872885d876 -r 18b0e4d1ae58 kallithea/lib/helpers.py --- 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\ \=>\ *([a-zA-Z0-9\/\=\?\&\ \:\/\.\-]*)\]', '
see => \\1
', value) - value = re.sub(r'\[license\ \=\>\ *([a-zA-Z0-9\/\=\?\&\ \:\/\.\-]*)\]', + value = re.sub(r'\[license\ \=>\ *([a-zA-Z0-9\/\=\?\&\ \:\/\.\-]*)\]', '
\\1
', value) - value = re.sub(r'\[(requires|recommends|conflicts|base)\ \=\>\ *([a-zA-Z0-9\-\/]*)\]', + value = re.sub(r'\[(requires|recommends|conflicts|base)\ \=>\ *([a-zA-Z0-9\-\/]*)\]', '
\\1 => \\2
', value) - value = re.sub(r'\[(lang|language)\ \=\>\ *([a-zA-Z\-\/\#\+]*)\]', + value = re.sub(r'\[(lang|language)\ \=>\ *([a-zA-Z\-\/\#\+]*)\]', '
\\2
', value) value = re.sub(r'\[([a-z]+)\]', '
\\1
', value) diff -r 65872885d876 -r 18b0e4d1ae58 kallithea/tests/other/test_libs.py --- 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('
tag
' in res) self.assertTrue('
obsolete
' in res) self.assertTrue('
stale
' in res)