commit 8f0f55ccba0ba4cea24df189b096194365da0e28
Author: Claude Paroz <claude@2xlibre.net>
Date: Thu Dec 23 22:03:27 2010 +0100
Encode url before passing it to urllib2
diff --git a/django/core/validators.py b/django/core/validators.py
index b1b82db..65a980b 100644
a
|
b
|
class URLValidator(RegexValidator):
|
81 | 81 | "User-Agent": self.user_agent, |
82 | 82 | } |
83 | 83 | try: |
84 | | req = urllib2.Request(url, None, headers) |
| 84 | req = urllib2.Request(url.encode('utf-8'), None, headers) |
85 | 85 | u = urllib2.urlopen(req) |
86 | 86 | except ValueError: |
87 | 87 | raise ValidationError(_(u'Enter a valid URL.'), code='invalid') |
diff --git a/tests/regressiontests/forms/tests/fields.py b/tests/regressiontests/forms/tests/fields.py
index 93ca5c1..9302b85 100644
a
|
b
|
class FieldsTests(TestCase):
|
539 | 539 | f.clean(u'http://broken.עברית.idn.icann.org/') |
540 | 540 | except ValidationError, e: |
541 | 541 | self.assertEqual("[u'This URL appears to be a broken link.']", str(e)) |
| 542 | # UTF-8 char in path |
| 543 | self.assertEqual(u'http://de.wikipedia.org/wiki/T\xfcr', f.clean(u'http://de.wikipedia.org/wiki/T\xfcr')) |
542 | 544 | |
543 | 545 | def test_urlfield_4(self): |
544 | 546 | f = URLField(verify_exists=True, required=False) |