Ticket #11911: 11911-and-12183.patch
File 11911-and-12183.patch, 1.8 KB (added by , 14 years ago) |
---|
-
django/utils/html.py
92 92 If autoescape is True, the link text and URLs will get autoescaped. 93 93 """ 94 94 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 95 fix_trailing_bracket = lambda lead, middle, trail: (middle + ')', trail[1:]) if (trail.startswith(')') and not lead.endswith('(')) else (middle, trail) 95 96 safe_input = isinstance(text, SafeData) 96 97 words = word_split_re.split(force_unicode(text)) 97 nofollow_attr = nofollow and ' rel="nofollow"' or ''98 98 for i, word in enumerate(words): 99 nofollow_attr = nofollow and ' rel="nofollow"' or '' 99 100 match = None 100 101 if '.' in word or '@' in word or ':' in word: 101 102 match = punctuation_re.match(word) … … 104 105 # Make URL we want to point to. 105 106 url = None 106 107 if middle.startswith('http://') or middle.startswith('https://'): 108 middle, trail = fix_trailing_bracket(lead, middle, trail) 107 109 url = urlquote(middle, safe='/&=:;#?+*') 108 110 elif middle.startswith('www.') or ('@' not in middle and \ 109 111 middle and middle[0] in string.ascii_letters + string.digits and \ 110 112 (middle.endswith('.org') or middle.endswith('.net') or middle.endswith('.com'))): 113 middle, trail = fix_trailing_bracket(lead, middle, trail) 111 114 url = urlquote('http://%s' % middle, safe='/&=:;#?+*') 112 115 elif '@' in middle and not ':' in middle and simple_email_re.match(middle): 113 116 url = 'mailto:%s' % middle