diff --git a/kallithea/lib/helpers.py b/kallithea/lib/helpers.py --- a/kallithea/lib/helpers.py +++ b/kallithea/lib/helpers.py @@ -1289,7 +1289,9 @@ def urlify_text(s, repo_name=None, link_ Issues are linked to given issue-server. If link_ is provided, all text not already linking somewhere will link there. """ - if truncate is not None: + if truncate is None: + s = s.rstrip() + else: s = truncatef(s, truncate, whole_word=True) s = html_escape(s) if repo_name is not None: @@ -1299,6 +1301,7 @@ def urlify_text(s, repo_name=None, link_ s = _urlify_text(s) if repo_name is not None: s = urlify_issues(s, repo_name, link_) + s = MENTIONS_REGEX.sub(_mentions_replace, s) return literal(s) @@ -1411,17 +1414,8 @@ def render_w_mentions(source, repo_name= Render plain text with revision hashes and issue references urlified and with @mention highlighting. """ - s = source.rstrip() - s = safe_unicode(s) - s = '\n'.join(s.splitlines()) - s = html_escape(s) - # this sequence of html-ifications seems to be safe and non-conflicting - # if the issues regexp is sane - s = _urlify_text(s) - if repo_name is not None: - s = urlify_changesets(s, repo_name) - s = urlify_issues(s, repo_name) - s = MENTIONS_REGEX.sub(_mentions_replace, s) + s = safe_unicode(source) + s = urlify_text(s, repo_name=repo_name) return literal('
%s
' % s) diff --git a/kallithea/tests/other/test_libs.py b/kallithea/tests/other/test_libs.py --- a/kallithea/tests/other/test_libs.py +++ b/kallithea/tests/other/test_libs.py @@ -311,8 +311,7 @@ class TestLibs(TestController): """Multi line\n""" """ url[123123123123]\n""" """ some text url[123123123123]\n""" - """ sometimes !\n""" - """ """), + """ sometimes !"""), ]) def test_urlify_changesets(self, sample, expected): def fake_url(self, *args, **kwargs): @@ -348,7 +347,7 @@ class TestLibs(TestController): """ some text lalala""", "https://foo.bar.example.com"), ("@mention @someone", - """@mention @someone""", + """@mention @someone""", ""), ("deadbeefcafe 123412341234", """deadbeefcafe 123412341234""", @@ -365,7 +364,7 @@ class TestLibs(TestController): ("deadbeefcafe @mention, and http://foo.bar/ yo", """""" """deadbeefcafe""" - """ @mention, and """ + """ @mention, and """ """http://foo.bar/""" """ yo"""), ])