[1.2.X] Fixed #14941 -- Stop raising ValidationError in form fields that use the URLValidator and get a IDN domain passed. Thanks, Claude Paroz.
Backport from trunk (r15504). git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@15511 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
89c03dcbf3
commit
748110cb94
|
@ -81,7 +81,7 @@ class URLValidator(RegexValidator):
|
||||||
"User-Agent": self.user_agent,
|
"User-Agent": self.user_agent,
|
||||||
}
|
}
|
||||||
try:
|
try:
|
||||||
req = urllib2.Request(url, None, headers)
|
req = urllib2.Request(url.encode('utf-8'), None, headers)
|
||||||
u = urllib2.urlopen(req)
|
u = urllib2.urlopen(req)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise ValidationError(_(u'Enter a valid URL.'), code='invalid')
|
raise ValidationError(_(u'Enter a valid URL.'), code='invalid')
|
||||||
|
|
|
@ -567,6 +567,8 @@ class FieldsTests(TestCase):
|
||||||
f.clean('http://google.com/we-love-microsoft.html') # good domain, bad page
|
f.clean('http://google.com/we-love-microsoft.html') # good domain, bad page
|
||||||
except ValidationError, e:
|
except ValidationError, e:
|
||||||
self.assertEqual("[u'This URL appears to be a broken link.']", str(e))
|
self.assertEqual("[u'This URL appears to be a broken link.']", str(e))
|
||||||
|
# UTF-8 char in path
|
||||||
|
self.assertEqual(u'http://de.wikipedia.org/wiki/T\xfcr', f.clean(u'http://de.wikipedia.org/wiki/T\xfcr'))
|
||||||
|
|
||||||
def test_urlfield_4(self):
|
def test_urlfield_4(self):
|
||||||
f = URLField(verify_exists=True, required=False)
|
f = URLField(verify_exists=True, required=False)
|
||||||
|
|
Loading…
Reference in New Issue