Ticket #6965: faster_urlize_r7936_t6965.diff
File faster_urlize_r7936_t6965.diff, 1.3 KB (added by , 16 years ago) |
---|
-
django/utils/html.py
94 94 words = word_split_re.split(force_unicode(text)) 95 95 nofollow_attr = nofollow and ' rel="nofollow"' or '' 96 96 for i, word in enumerate(words): 97 match = punctuation_re.match(word) 97 match = None 98 if '.' in word or '@' in word or ':' in word: 99 match = punctuation_re.match(word) 98 100 if match: 99 101 lead, middle, trail = match.groups() 100 102 # Make URL we want to point to. … … 102 104 if middle.startswith('http://') or middle.startswith('https://'): 103 105 url = urlquote(middle, safe='/&=:;#?+*') 104 106 elif middle.startswith('www.') or ('@' not in middle and \ 105 len(middle) > 0and middle[0] in string.ascii_letters + string.digits and \107 middle and middle[0] in string.ascii_letters + string.digits and \ 106 108 (middle.endswith('.org') or middle.endswith('.net') or middle.endswith('.com'))): 107 109 url = urlquote('http://%s' % middle, safe='/&=:;#?+*') 108 110 elif '@' in middle and not ':' in middle and simple_email_re.match(middle):