Ticket #11911: 11911.patch
File 11911.patch, 2.5 KB (added by , 13 years ago) |
---|
-
tests/regressiontests/defaultfilters/tests.py
200 200 u'<a href="http://31characteruri.com/test/"'\ 201 201 u' rel="nofollow">...</a>') 202 202 203 # Test url with brackets in it (#11911) 204 205 uri = 'http://en.wikipedia.org/wiki/Sibiu(Romania)' 206 self.assertEqual(urlizetrunc(uri, 200), 207 u'<a href="http://en.wikipedia.org/wiki/Sibiu%28Romania%29" '\ 208 u'rel="nofollow">http://en.wikipedia.org/wiki/Sibiu(Romania)</a>') 209 self.assertEqual(urlizetrunc(uri, 40), 210 u'<a href="http://en.wikipedia.org/wiki/Sibiu%28Romania%29" '\ 211 u'rel="nofollow">http://en.wikipedia.org/wiki/Sibiu(Ro...</a>') 212 203 213 def test_urlize(self): 204 214 # Check normal urlize 205 215 self.assertEqual(urlize('http://google.com'), -
django/utils/html.py
117 117 If autoescape is True, the link text and URLs will get autoescaped. 118 118 """ 119 119 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 120 fix_trailing_bracket = lambda lead, middle, trail: (middle + ')', trail[1:]) if (trail.startswith(')') and not lead.endswith('(')) else (middle, trail) 120 121 safe_input = isinstance(text, SafeData) 121 122 words = word_split_re.split(force_unicode(text)) 122 123 nofollow_attr = nofollow and ' rel="nofollow"' or '' … … 129 130 # Make URL we want to point to. 130 131 url = None 131 132 if middle.startswith('http://') or middle.startswith('https://'): 133 middle, trail = fix_trailing_bracket(lead, middle, trail) 132 134 url = urlquote(middle, safe='/&=:;#?+*') 133 135 elif middle.startswith('www.') or ('@' not in middle and \ 134 136 middle and middle[0] in string.ascii_letters + string.digits and \ 135 137 (middle.endswith('.org') or middle.endswith('.net') or middle.endswith('.com'))): 138 middle, trail = fix_trailing_bracket(lead, middle, trail) 136 139 url = urlquote('http://%s' % middle, safe='/&=:;#?+*') 137 140 elif '@' in middle and not ':' in middle and simple_email_re.match(middle): 138 141 url = 'mailto:%s' % middle