Mercurial > p > roundup > code
comparison test/test_templating.py @ 5190:89b1870b1bc9
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.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sat, 25 Feb 2017 21:01:50 -0500 |
| parents | ae2a5d1afdd5 |
| children | a9ace22e0a2f |
comparison
equal
deleted
inserted
replaced
| 5189:7aebd892b600 | 5190:89b1870b1bc9 |
|---|---|
| 176 p = StringHTMLProperty(self.client, 'test', '1', None, 'test', '') | 176 p = StringHTMLProperty(self.client, 'test', '1', None, 'test', '') |
| 177 def t(s): return p.hyper_re.sub(p._hyper_repl, s) | 177 def t(s): return p.hyper_re.sub(p._hyper_repl, s) |
| 178 ae = self.assertEqual | 178 ae = self.assertEqual |
| 179 ae(t('item123123123123'), 'item123123123123') | 179 ae(t('item123123123123'), 'item123123123123') |
| 180 ae(t('http://roundup.net/'), | 180 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>') |
| 182 ae(t('<HTTP://roundup.net/>'), | 182 ae(t('<HTTP://roundup.net/>'), |
| 183 '<<a href="HTTP://roundup.net/">HTTP://roundup.net/</a>>') | 183 '<<a href="HTTP://roundup.net/" rel="nofollow">HTTP://roundup.net/</a>>') |
| 184 ae(t('<http://roundup.net/>.'), | 184 ae(t('<http://roundup.net/>.'), |
| 185 '<<a href="http://roundup.net/">http://roundup.net/</a>>.') | 185 '<<a href="http://roundup.net/" rel="nofollow">http://roundup.net/</a>>.') |
| 186 ae(t('<www.roundup.net>'), | 186 ae(t('<www.roundup.net>'), |
| 187 '<<a href="http://www.roundup.net">www.roundup.net</a>>') | 187 '<<a href="http://www.roundup.net" rel="nofollow">www.roundup.net</a>>') |
| 188 ae(t('(www.roundup.net)'), | 188 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>)') |
| 190 ae(t('foo http://msdn.microsoft.com/en-us/library/ms741540(VS.85).aspx bar'), | 190 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">' |
| 192 'http://msdn.microsoft.com/en-us/library/ms741540(VS.85).aspx</a> bar') | 192 'http://msdn.microsoft.com/en-us/library/ms741540(VS.85).aspx</a> bar') |
| 193 ae(t('(e.g. http://en.wikipedia.org/wiki/Python_(programming_language))'), | 193 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">' |
| 195 'http://en.wikipedia.org/wiki/Python_(programming_language)</a>)') | 195 'http://en.wikipedia.org/wiki/Python_(programming_language)</a>)') |
| 196 ae(t('(e.g. http://en.wikipedia.org/wiki/Python_(programming_language)).'), | 196 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">' |
| 198 'http://en.wikipedia.org/wiki/Python_(programming_language)</a>).') | 198 'http://en.wikipedia.org/wiki/Python_(programming_language)</a>).') |
| 199 ae(t('(e.g. http://en.wikipedia.org/wiki/Python_(programming_language))>.'), | 199 ae(t('(e.g. http://en.wikipedia.org/wiki/Python_(programming_language))>.'), |
| 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">' |
| 201 'http://en.wikipedia.org/wiki/Python_(programming_language)</a>)>.') | 201 'http://en.wikipedia.org/wiki/Python_(programming_language)</a>)>.') |
| 202 ae(t('(e.g. http://en.wikipedia.org/wiki/Python_(programming_language>)).'), | 202 ae(t('(e.g. http://en.wikipedia.org/wiki/Python_(programming_language>)).'), |
| 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">' |
| 204 'http://en.wikipedia.org/wiki/Python_(programming_language</a>>)).') | 204 'http://en.wikipedia.org/wiki/Python_(programming_language</a>>)).') |
| 205 for c in '.,;:!': | 205 for c in '.,;:!': |
| 206 # trailing punctuation is not included | 206 # trailing punctuation is not included |
| 207 ae(t('http://roundup.net/%c ' % c), | 207 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) |
| 209 # but it's included if it's part of the URL | 209 # but it's included if it's part of the URL |
| 210 ae(t('http://roundup.net/%c/' % c), | 210 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)) |
| 212 | 212 |
| 213 ''' | 213 ''' |
| 214 class HTMLPermissions: | 214 class HTMLPermissions: |
| 215 def is_edit_ok(self): | 215 def is_edit_ok(self): |
| 216 def is_view_ok(self): | 216 def is_view_ok(self): |
