Ticket #14941: urlvalidator.diff

File urlvalidator.diff, 585 bytes (added by claudep, 4 years ago)

Encode url before passing it to urllib2.urlopen

  • django/core/validators.py

    diff --git a/django/core/validators.py b/django/core/validators.py
    index b1b82db..65a980b 100644
    a b class URLValidator(RegexValidator): 
    8181                "User-Agent": self.user_agent,
    8282            }
    8383            try:
    84                 req = urllib2.Request(url, None, headers)
     84                req = urllib2.Request(url.encode('utf-8'), None, headers)
    8585                u = urllib2.urlopen(req)
    8686            except ValueError:
    8787                raise ValidationError(_(u'Enter a valid URL.'), code='invalid')
Back to Top