summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4ced068)
raw | patch | inline | side by side (parent: 4ced068)
author | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Thu, 12 Aug 2010 05:00:07 +0000 (05:00 +0000) | ||
committer | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Thu, 12 Aug 2010 05:00:07 +0000 (05:00 +0000) |
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/roundup/trunk@4519 57a73879-2fb5-44c3-a270-3262357dd7e2
CHANGES.txt | patch | blob | history | |
roundup/cgi/templating.py | patch | blob | history | |
test/test_templating.py | patch | blob | history |
diff --git a/CHANGES.txt b/CHANGES.txt
index 675e0c615cfbcd760eec72a581ae99faf2dadb06..d0a8950e6cfb78a51d98411573ad0e46bf747989 100644 (file)
--- a/CHANGES.txt
+++ b/CHANGES.txt
- fix for incorrect except: syntax, issue2550661 (thanks Jakub Wilk)
- No longer use the root logger, use a logger with prefix "roundup",
see http://thread.gmane.org/gmane.comp.bug-tracking.roundup.devel/5356
+- improve handling of '>' when URLs are converted to links, issue2550664
+ (thanks Ezio Melotti)
2010-07-12 1.4.15
index 9176420f55abedd00debfb8553b1880df259f26b..a08dbcd85729d055777098c8e9e9174f91a17d00 100644 (file)
u = s = match.group('url')
if not self.protocol_re.search(s):
u = 'http://' + s
- if s.endswith('>'):
- # catch an escaped ">" at the end of the URL
- u = s = s[:-4]
- e = '>'
- elif s.count('(') != s.count(')'):
+ end = ''
+ if '>' in s:
+ # catch an escaped ">" in the URL
+ pos = s.find('>')
+ end = s[pos:]
+ u = s = s[:pos]
+ if ')' in s and s.count('(') != s.count(')'):
# don't include extraneous ')' in the link
pos = s.rfind(')')
- e = s[pos:]
+ end = s[pos:] + end
u = s = s[:pos]
- else:
- e = ''
- return replacement % (u, s, e)
+ return replacement % (u, s, end)
def _hyper_repl_email(self, match, replacement):
s = match.group('email')
index d176842d4c7fcc8be07458103b37935a7a8aa979..e4244d1da4d24a40cda17a38da8d771a89ff0d3e 100644 (file)
--- a/test/test_templating.py
+++ b/test/test_templating.py
def test_url_replace(self):
p = StringHTMLProperty(self.client, 'test', '1', None, 'test', '')
def t(s): return p.hyper_re.sub(p._hyper_repl, s)
- ae = self.assertEquals
+ ae = self.assertEqual
ae(t('item123123123123'), 'item123123123123')
ae(t('http://roundup.net/'),
'<a href="http://roundup.net/">http://roundup.net/</a>')
ae(t('<HTTP://roundup.net/>'),
'<<a href="HTTP://roundup.net/">HTTP://roundup.net/</a>>')
+ ae(t('<http://roundup.net/>.'),
+ '<<a href="http://roundup.net/">http://roundup.net/</a>>.')
ae(t('<www.roundup.net>'),
'<<a href="http://www.roundup.net">www.roundup.net</a>>')
ae(t('(www.roundup.net)'),
ae(t('(e.g. http://en.wikipedia.org/wiki/Python_(programming_language)).'),
'(e.g. <a href="http://en.wikipedia.org/wiki/Python_(programming_language)">'
'http://en.wikipedia.org/wiki/Python_(programming_language)</a>).')
+ ae(t('(e.g. http://en.wikipedia.org/wiki/Python_(programming_language))>.'),
+ '(e.g. <a href="http://en.wikipedia.org/wiki/Python_(programming_language)">'
+ 'http://en.wikipedia.org/wiki/Python_(programming_language)</a>)>.')
+ ae(t('(e.g. http://en.wikipedia.org/wiki/Python_(programming_language>)).'),
+ '(e.g. <a href="http://en.wikipedia.org/wiki/Python_(programming_language">'
+ 'http://en.wikipedia.org/wiki/Python_(programming_language</a>>)).')
'''
class HTMLPermissions: