diff options
| author | Claude Paroz <claude@2xlibre.net> | 2012-08-11 22:44:42 +0200 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2012-08-11 23:23:31 +0200 |
| commit | 900816464dbd7b1fcc009177f9de03791edc6e88 (patch) | |
| tree | e3f60f78781d4e8933130b740b96170d992eb9b0 | |
| parent | 66021033381f154ddf8a9ecf93fcbb41a7abda17 (diff) | |
[py3] Re-decoded string after idna encoding
| -rw-r--r-- | django/core/validators.py | 4 | ||||
| -rw-r--r-- | django/utils/html.py | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/django/core/validators.py b/django/core/validators.py index 456fa3cec5..34c397506f 100644 --- a/django/core/validators.py +++ b/django/core/validators.py @@ -57,7 +57,7 @@ class URLValidator(RegexValidator): value = smart_text(value) scheme, netloc, path, query, fragment = urlsplit(value) try: - netloc = netloc.encode('idna') # IDN -> ACE + netloc = netloc.encode('idna').decode('ascii') # IDN -> ACE except UnicodeError: # invalid domain part raise e url = urlunsplit((scheme, netloc, path, query, fragment)) @@ -84,7 +84,7 @@ class EmailValidator(RegexValidator): if value and '@' in value: parts = value.split('@') try: - parts[-1] = parts[-1].encode('idna') + parts[-1] = parts[-1].encode('idna').decode('ascii') except UnicodeError: raise e super(EmailValidator, self).__call__('@'.join(parts)) diff --git a/django/utils/html.py b/django/utils/html.py index 7dd53a1353..647982a15f 100644 --- a/django/utils/html.py +++ b/django/utils/html.py @@ -143,7 +143,7 @@ def smart_urlquote(url): # Handle IDN before quoting. scheme, netloc, path, query, fragment = urlsplit(url) try: - netloc = netloc.encode('idna') # IDN -> ACE + netloc = netloc.encode('idna').decode('ascii') # IDN -> ACE except UnicodeError: # invalid domain part pass else: @@ -206,7 +206,7 @@ def urlize(text, trim_url_limit=None, nofollow=False, autoescape=False): elif not ':' in middle and simple_email_re.match(middle): local, domain = middle.rsplit('@', 1) try: - domain = domain.encode('idna') + domain = domain.encode('idna').decode('ascii') except UnicodeError: continue url = 'mailto:%s@%s' % (local, domain) |
