Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[py3] Re-decoded string after idna encoding

  • Loading branch information...
commit 900816464dbd7b1fcc009177f9de03791edc6e88 1 parent 6602103
@claudep claudep authored
Showing with 4 additions and 4 deletions.
  1. +2 −2 django/core/validators.py
  2. +2 −2 django/utils/html.py
View
4 django/core/validators.py
@@ -57,7 +57,7 @@ def __call__(self, value):
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 @@ def __call__(self, value):
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))
View
4 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)
Please sign in to comment.
Something went wrong with that request. Please try again.