Author: aaugustin Date: 2012-01-08 01:51:36 -0800 (Sun, 08 Jan 2012) New Revision: 17356
Modified: django/trunk/django/utils/html.py django/trunk/tests/regressiontests/defaultfilters/tests.py Log: Fixed #12183 -- Made the urlize filter insert the nofollow attribute properly when an http: URL occurs after a mailto: URL. Thanks eronen for the report. Modified: django/trunk/django/utils/html.py =================================================================== --- django/trunk/django/utils/html.py 2012-01-07 21:52:07 UTC (rev 17355) +++ django/trunk/django/utils/html.py 2012-01-08 09:51:36 UTC (rev 17356) @@ -141,7 +141,6 @@ trim_url = lambda x, limit=trim_url_limit: limit is not None and (len(x) > limit and ('%s...' % x[:max(0, limit - 3)])) or x safe_input = isinstance(text, SafeData) words = word_split_re.split(force_unicode(text)) - nofollow_attr = nofollow and ' rel="nofollow"' or '' for i, word in enumerate(words): match = None if '.' in word or '@' in word or ':' in word: @@ -150,6 +149,7 @@ lead, middle, trail = match.groups() # Make URL we want to point to. url = None + nofollow_attr = ' rel="nofollow"' if nofollow else '' if middle.startswith('http://') or middle.startswith('https://'): url = smart_urlquote(middle) elif middle.startswith('www.') or ('@' not in middle and \ Modified: django/trunk/tests/regressiontests/defaultfilters/tests.py =================================================================== --- django/trunk/tests/regressiontests/defaultfilters/tests.py 2012-01-07 21:52:07 UTC (rev 17355) +++ django/trunk/tests/regressiontests/defaultfilters/tests.py 2012-01-08 09:51:36 UTC (rev 17356) @@ -253,6 +253,11 @@ u'<a href="http://en.wikipedia.org/wiki/Caf%C3%A9" rel="nofollow">' u'http://en.wikipedia.org/wiki/Café</a>') + # Check urlize adds nofollow properly - see #12183 + self.assertEqual(urlize('f...@bar.com or www.bar.com'), + u'<a href="mailto:f...@bar.com">f...@bar.com</a> or ' + u'<a href="http://www.bar.com" rel="nofollow">www.bar.com</a>') + # Check urlize handles IDN correctly - see #13704 self.assertEqual(urlize('http://c✶.ws'), u'<a href="http://xn--c-lgq.ws" rel="nofollow">http://c✶.ws</a>') -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.