diff --git a/kallithea/lib/helpers.py b/kallithea/lib/helpers.py
--- a/kallithea/lib/helpers.py
+++ b/kallithea/lib/helpers.py
@@ -85,7 +85,7 @@ def html_escape(s):
.replace(">", ">")
.replace("<", "<")
.replace('"', """)
- .replace("'", "'") # some mail readers use HTML 4 and doesn't support '
+ .replace("'", "'") # Note: this is HTML5 not HTML4 and might not work in mails
)
def js(value):
@@ -1092,6 +1092,10 @@ def urlify_text(s, repo_name=None, link_
# make href around everything that isn't a href already
s = linkify_others(s, link_)
s = s.replace('\r\n', '
').replace('\n', '
')
+ # Turn HTML5 into more valid HTML4 as required by some mail readers.
+ # (This is not done in one step in html_escape, because character codes like
+ # { risk to be seen as an issue reference due to the presence of '#'.)
+ s = s.replace("'", "'")
return literal(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
@@ -381,8 +381,7 @@ class TestLibs(TestController):
"""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> 'single' "double" &pointer""",
+ "HTML escaping: <abc> 'single' "double" &pointer",
"-"),
# tags are covered by test_tag_extractor
])
@@ -420,11 +419,10 @@ 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 'standard' text with apostrophes'),
+ "some 'standard' text with apostrophes", 'some 'standard' text with apostrophes'),
(r'#(\d+)', 'http://foo/{repo}/issue/{id}', '#',
- "some 'standard' issue #123", 'some 'standard' issue #123'),
+ "some 'standard' issue #123", 'some 'standard' issue #123'),
])
def test_urlify_issues(self, issue_pat, issue_server, issue_prefix, sample, expected):
from kallithea.lib.helpers import urlify_text