Skip to content

Commit 9e501e9

Browse files
committed
Make url's in messages identified as http://... or https://...
have the rel="nofollow" attribute to reduce the value of spamming public trackers. Internal links: issue20 msg10 etc. won't have the nofollow attribute.
1 parent 11b8d1d commit 9e501e9

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

CHANGES.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,11 @@ Features:
424424
- Add RejectRaw exception to allow unescaped HTML error messages to be
425425
displayed to the user (thanks Ezio Melotti for the initial patch)
426426
(John Kristensen)
427+
- Add rel=nofollow to http and https url's in the body of messages.
428+
This should reduce the value of a public roundup tracker to spammers.
429+
References like issue20 or msg10 will hyperlink without
430+
rel=nofollow so that robots can index them. Similar work was done
431+
for the history display in roundup 1.5.0. (John Rouillard)
427432

428433
Fixed:
429434

roundup/cgi/templating.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1337,7 +1337,7 @@ class StringHTMLProperty(HTMLProperty):
13371337

13381338
def _hyper_repl(self, match):
13391339
if match.group('url'):
1340-
return self._hyper_repl_url(match, '<a href="%s">%s</a>%s')
1340+
return self._hyper_repl_url(match, '<a href="%s" rel="nofollow">%s</a>%s')
13411341
elif match.group('email'):
13421342
return self._hyper_repl_email(match, '<a href="mailto:%s">%s</a>')
13431343
elif len(match.group('id')) < 10:

test/test_templating.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -178,37 +178,37 @@ def t(s): return p.hyper_re.sub(p._hyper_repl, s)
178178
ae = self.assertEqual
179179
ae(t('item123123123123'), 'item123123123123')
180180
ae(t('http://roundup.net/'),
181-
'<a href="http://roundup.net/">http://roundup.net/</a>')
181+
'<a href="http://roundup.net/" rel="nofollow">http://roundup.net/</a>')
182182
ae(t('&lt;HTTP://roundup.net/&gt;'),
183-
'&lt;<a href="HTTP://roundup.net/">HTTP://roundup.net/</a>&gt;')
183+
'&lt;<a href="HTTP://roundup.net/" rel="nofollow">HTTP://roundup.net/</a>&gt;')
184184
ae(t('&lt;http://roundup.net/&gt;.'),
185-
'&lt;<a href="http://roundup.net/">http://roundup.net/</a>&gt;.')
185+
'&lt;<a href="http://roundup.net/" rel="nofollow">http://roundup.net/</a>&gt;.')
186186
ae(t('&lt;www.roundup.net&gt;'),
187-
'&lt;<a href="http://www.roundup.net">www.roundup.net</a>&gt;')
187+
'&lt;<a href="http://www.roundup.net" rel="nofollow">www.roundup.net</a>&gt;')
188188
ae(t('(www.roundup.net)'),
189-
'(<a href="http://www.roundup.net">www.roundup.net</a>)')
189+
'(<a href="http://www.roundup.net" rel="nofollow">www.roundup.net</a>)')
190190
ae(t('foo http://msdn.microsoft.com/en-us/library/ms741540(VS.85).aspx bar'),
191-
'foo <a href="http://msdn.microsoft.com/en-us/library/ms741540(VS.85).aspx">'
191+
'foo <a href="http://msdn.microsoft.com/en-us/library/ms741540(VS.85).aspx" rel="nofollow">'
192192
'http://msdn.microsoft.com/en-us/library/ms741540(VS.85).aspx</a> bar')
193193
ae(t('(e.g. http://en.wikipedia.org/wiki/Python_(programming_language))'),
194-
'(e.g. <a href="http://en.wikipedia.org/wiki/Python_(programming_language)">'
194+
'(e.g. <a href="http://en.wikipedia.org/wiki/Python_(programming_language)" rel="nofollow">'
195195
'http://en.wikipedia.org/wiki/Python_(programming_language)</a>)')
196196
ae(t('(e.g. http://en.wikipedia.org/wiki/Python_(programming_language)).'),
197-
'(e.g. <a href="http://en.wikipedia.org/wiki/Python_(programming_language)">'
197+
'(e.g. <a href="http://en.wikipedia.org/wiki/Python_(programming_language)" rel="nofollow">'
198198
'http://en.wikipedia.org/wiki/Python_(programming_language)</a>).')
199199
ae(t('(e.g. http://en.wikipedia.org/wiki/Python_(programming_language))&gt;.'),
200-
'(e.g. <a href="http://en.wikipedia.org/wiki/Python_(programming_language)">'
200+
'(e.g. <a href="http://en.wikipedia.org/wiki/Python_(programming_language)" rel="nofollow">'
201201
'http://en.wikipedia.org/wiki/Python_(programming_language)</a>)&gt;.')
202202
ae(t('(e.g. http://en.wikipedia.org/wiki/Python_(programming_language&gt;)).'),
203-
'(e.g. <a href="http://en.wikipedia.org/wiki/Python_(programming_language">'
203+
'(e.g. <a href="http://en.wikipedia.org/wiki/Python_(programming_language" rel="nofollow">'
204204
'http://en.wikipedia.org/wiki/Python_(programming_language</a>&gt;)).')
205205
for c in '.,;:!':
206206
# trailing punctuation is not included
207207
ae(t('http://roundup.net/%c ' % c),
208-
'<a href="http://roundup.net/">http://roundup.net/</a>%c ' % c)
208+
'<a href="http://roundup.net/" rel="nofollow">http://roundup.net/</a>%c ' % c)
209209
# but it's included if it's part of the URL
210210
ae(t('http://roundup.net/%c/' % c),
211-
'<a href="http://roundup.net/%c/">http://roundup.net/%c/</a>' % (c, c))
211+
'<a href="http://roundup.net/%c/" rel="nofollow">http://roundup.net/%c/</a>' % (c, c))
212212

213213
'''
214214
class HTMLPermissions:

0 commit comments

Comments
 (0)