diff --git a/rhodecode/lib/helpers.py b/rhodecode/lib/helpers.py --- a/rhodecode/lib/helpers.py +++ b/rhodecode/lib/helpers.py @@ -659,3 +659,15 @@ def fancy_file_stats(stats): d_d = '
%s
' % (cgen('d'), d_p, d_v) return literal('
%s%s
' % (width, d_a, d_d)) + + +def urlify_text(text): + import re + + url_pat = re.compile(r'(http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+)') + + def url_func(match_obj): + url_full = match_obj.groups()[0] + return '%(url)s' % ({'url':url_full}) + + return literal(url_pat.sub(url_func, text))