Mercurial > p > roundup > code
diff roundup/cgi/templating.py @ 4413:66603a9051f9
improve handling of '>' when URLs are converted to links
issue2550664 (thanks Ezio Melotti)
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Thu, 12 Aug 2010 05:00:07 +0000 |
| parents | 172489ea9e07 |
| children | cc36be59ebd8 |
line wrap: on
line diff
--- a/roundup/cgi/templating.py Mon Aug 09 09:04:19 2010 +0000 +++ b/roundup/cgi/templating.py Thu Aug 12 05:00:07 2010 +0000 @@ -1361,18 +1361,18 @@ 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')
