From: <ri...@us...> - 2010-07-12 04:14:08
|
Revision: 4497 http://roundup.svn.sourceforge.net/roundup/?rev=4497&view=rev Author: richard Date: 2010-07-12 04:14:02 +0000 (Mon, 12 Jul 2010) Log Message: ----------- make URL detection a little smarter about brackets per issue2550657 (thanks Ezio Melotti) Modified Paths: -------------- roundup/trunk/CHANGES.txt roundup/trunk/doc/acknowledgements.txt roundup/trunk/roundup/cgi/templating.py roundup/trunk/test/test_templating.py Modified: roundup/trunk/CHANGES.txt =================================================================== --- roundup/trunk/CHANGES.txt 2010-07-12 04:11:05 UTC (rev 4496) +++ roundup/trunk/CHANGES.txt 2010-07-12 04:14:02 UTC (rev 4497) @@ -6,6 +6,8 @@ Fixed: - A bunch of regressions were introduced in the last release making Roundup no longer work in Python releases prior to 2.6 +- make URL detection a little smarter about brackets per issue2550657 + (thanks Ezio Melotti) 2010-07-01 1.4.14 Modified: roundup/trunk/doc/acknowledgements.txt =================================================================== --- roundup/trunk/doc/acknowledgements.txt 2010-07-12 04:11:05 UTC (rev 4496) +++ roundup/trunk/doc/acknowledgements.txt 2010-07-12 04:14:02 UTC (rev 4497) @@ -84,6 +84,7 @@ Gordon McMillan, John F Meinel Jr, Roland Meister, +Ezio Melotti, Ulrik Mikaelsson, John Mitchell, Ramiro Morales, Modified: roundup/trunk/roundup/cgi/templating.py =================================================================== --- roundup/trunk/roundup/cgi/templating.py 2010-07-12 04:11:05 UTC (rev 4496) +++ roundup/trunk/roundup/cgi/templating.py 2010-07-12 04:14:02 UTC (rev 4497) @@ -1361,16 +1361,21 @@ u = s = match.group('url') if not self.protocol_re.search(s): u = 'http://' + s - # catch an escaped ">" at the end of the URL if s.endswith('>'): + # catch an escaped ">" at the end of the URL u = s = s[:-4] e = '>' + elif s.count('(') != s.count(')'): + # don't include extraneous ')' in the link + pos = s.rfind(')') + e = s[pos:] + u = s = s[:pos] else: e = '' - return '<a href="%s">%s</a>%s'%(u, s, e) + return '<a href="%s">%s</a>%s' % (u, s, e) elif match.group('email'): s = match.group('email') - return '<a href="mailto:%s">%s</a>'%(s, s) + return '<a href="mailto:%s">%s</a>' % (s, s) elif len(match.group('id')) < 10: return self._hyper_repl_item(match, '<a href="%(cls)s%(id)s">%(item)s</a>') Modified: roundup/trunk/test/test_templating.py =================================================================== --- roundup/trunk/test/test_templating.py 2010-07-12 04:11:05 UTC (rev 4496) +++ roundup/trunk/test/test_templating.py 2010-07-12 04:14:02 UTC (rev 4497) @@ -147,10 +147,24 @@ p = StringHTMLProperty(self.client, 'test', '1', None, 'test', '') def t(s): return p.hyper_re.sub(p._hyper_repl, s) ae = self.assertEquals - 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('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('<www.roundup.net>'), + '<<a href="http://www.roundup.net">www.roundup.net</a>>') + ae(t('(www.roundup.net)'), + '(<a href="http://www.roundup.net">www.roundup.net</a>)') + ae(t('foo http://msdn.microsoft.com/en-us/library/ms741540(VS.85).aspx bar'), + 'foo <a href="http://msdn.microsoft.com/en-us/library/ms741540(VS.85).aspx">' + 'http://msdn.microsoft.com/en-us/library/ms741540(VS.85).aspx</a> bar') + 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: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |