Django

Code

Changeset 7985

Show
Ignore:
Timestamp:
07/19/08 13:05:22 (1 year ago)
Author:
mtredinnick
Message:

Fixed #6965 -- Sped up the urlize and urlizetrunc filters. A nice patch from Andrew Badr.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/utils/html.py

    r7755 r7985  
    9595    nofollow_attr = nofollow and ' rel="nofollow"' or '' 
    9696    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) 
    98100        if match: 
    99101            lead, middle, trail = match.groups() 
     
    103105                url = urlquote(middle, safe='/&=:;#?+*') 
    104106            elif middle.startswith('www.') or ('@' not in middle and \ 
    105                     len(middle) > 0 and middle[0] in string.ascii_letters + string.digits and \ 
     107                    middle and middle[0] in string.ascii_letters + string.digits and \ 
    106108                    (middle.endswith('.org') or middle.endswith('.net') or middle.endswith('.com'))): 
    107109                url = urlquote('http://%s' % middle, safe='/&=:;#?+*')