Ticket #16020: urlize_test.diff
File urlize_test.diff, 2.0 KB (added by , 13 years ago) |
---|
-
tests/regressiontests/defaultfilters/tests.py
212 212 u'<a href="http://djangoproject.org" rel="nofollow">djangoproject.org</a>') 213 213 self.assertEqual(urlize('info@djangoproject.org'), 214 214 u'<a href="mailto:info@djangoproject.org">info@djangoproject.org</a>') 215 215 216 216 # Check urlize with https addresses 217 217 self.assertEqual(urlize('https://google.com'), 218 218 u'<a href="https://google.com" rel="nofollow">https://google.com</a>') 219 # Check with escaped characters 220 self.assertEqual(urlize('http://google.com/django%20project'), 221 u'<a href="http://google.com/django%20project" rel="nofollow">http://google.com/django%20project</a>') 222 219 223 220 224 def test_wordcount(self): 221 225 self.assertEqual(wordcount(''), 0) -
django/utils/html.py
129 129 # Make URL we want to point to. 130 130 url = None 131 131 if middle.startswith('http://') or middle.startswith('https://'): 132 url = urlquote(middle, safe='/&=:;#?+* ')132 url = urlquote(middle, safe='/&=:;#?+*%') 133 133 elif middle.startswith('www.') or ('@' not in middle and \ 134 134 middle and middle[0] in string.ascii_letters + string.digits and \ 135 135 (middle.endswith('.org') or middle.endswith('.net') or middle.endswith('.com'))): 136 url = urlquote('http://%s' % middle, safe='/&=:;#?+* ')136 url = urlquote('http://%s' % middle, safe='/&=:;#?+*%') 137 137 elif '@' in middle and not ':' in middle and simple_email_re.match(middle): 138 138 url = 'mailto:%s' % middle 139 139 nofollow_attr = ''