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 @@ -380,6 +380,10 @@ class TestLibs(TestController): """which must not come after whitespace """ """and not be followed by * or alphanumerical *characters*.""", "-"), + ("HTML escaping: 'single' \"double\" &pointer", + # problem: ' is encoded as ' which however is interpreted as #39 and expanded to a issue link + """HTML escaping: <abc> &#39;single&#39; "double" &pointer""", + "-"), # tags are covered by test_tag_extractor ]) def test_urlify_test(self, sample, expected, url_): @@ -416,9 +420,14 @@ class TestLibs(TestController): 'silly me, the URL does not contain {id}, BUG12345.', 'silly me, the URL does not contain {id}, BUG12345.'), (r'(PR-\d+)', 'http://foo/{repo}/issue/{id}', '', 'interesting issue #123, err PR-56', 'interesting issue #123, err PR-56'), + # problem: ' is encoded as ' which however is interpreted as #39 and expanded to a issue link + (r'#(\d+)', 'http://foo/{repo}/issue/{id}', '#', + "some 'standard' text with apostrophes", 'some &#39;standard&#39; text with apostrophes'), + (r'#(\d+)', 'http://foo/{repo}/issue/{id}', '#', + "some 'standard' issue #123", 'some &#39;standard&#39; issue #123'), ]) def test_urlify_issues(self, issue_pat, issue_server, issue_prefix, sample, expected): - from kallithea.lib.helpers import urlify_issues + from kallithea.lib.helpers import urlify_text config_stub = { 'sqlalchemy.url': 'foo', 'issue_pat': issue_pat, @@ -428,7 +437,7 @@ class TestLibs(TestController): # force recreation of lazy function with mock.patch('kallithea.lib.helpers._urlify_issues_f', None): with mock.patch('kallithea.CONFIG', config_stub): - assert urlify_issues(sample, 'repo_name') == expected + assert urlify_text(sample, 'repo_name') == expected @parametrize('sample,expected', [ ('abc X5', 'abc #5'), @@ -440,7 +449,7 @@ class TestLibs(TestController): ('issue FAILMORE89', 'issue FAILMORE89'), # no match because absent prefix ]) def test_urlify_issues_multiple_issue_patterns(self, sample, expected): - from kallithea.lib.helpers import urlify_issues + from kallithea.lib.helpers import urlify_text config_stub = { 'sqlalchemy.url': 'foo', 'issue_pat': 'X(\d+)', @@ -461,7 +470,7 @@ class TestLibs(TestController): # force recreation of lazy function with mock.patch('kallithea.lib.helpers._urlify_issues_f', None): with mock.patch('kallithea.CONFIG', config_stub): - assert urlify_issues(sample, 'repo_name') == expected + assert urlify_text(sample, 'repo_name') == expected @parametrize('test,expected', [ ("", None),