Ticket #13704: django.2.diff

File django.2.diff, 986 bytes (added by Daniel Ryan, 14 years ago)

Better Exception handling

  • django/utils/html.py

     
    22
    33import re
    44import string
     5from urlparse import urlparse, urlunparse
    56
    67from django.utils.safestring import SafeData, mark_safe
    78from django.utils.encoding import force_unicode
     
    104105            # Make URL we want to point to.
    105106            url = None
    106107            if middle.startswith('http://') or middle.startswith('https://'):
     108                try:
     109                    middle = urlparse(middle)
     110                    middle = urlunparse( ( middle.scheme, middle.netloc.encode('idna'), middle.path, middle.params, middle.query, middle.fragment ) )
     111                except ValueError:
     112                    pass
    107113                url = urlquote(middle, safe='/&=:;#?+*')
    108114            elif middle.startswith('www.') or ('@' not in middle and \
    109115                    middle and middle[0] in string.ascii_letters + string.digits and \
Back to Top