mirror of
https://github.com/django/django.git
synced 2024-12-27 03:25:58 +00:00
[py3] Re-decoded string after idna encoding
This commit is contained in:
parent
6602103338
commit
900816464d
@ -57,7 +57,7 @@ class URLValidator(RegexValidator):
|
|||||||
value = smart_text(value)
|
value = smart_text(value)
|
||||||
scheme, netloc, path, query, fragment = urlsplit(value)
|
scheme, netloc, path, query, fragment = urlsplit(value)
|
||||||
try:
|
try:
|
||||||
netloc = netloc.encode('idna') # IDN -> ACE
|
netloc = netloc.encode('idna').decode('ascii') # IDN -> ACE
|
||||||
except UnicodeError: # invalid domain part
|
except UnicodeError: # invalid domain part
|
||||||
raise e
|
raise e
|
||||||
url = urlunsplit((scheme, netloc, path, query, fragment))
|
url = urlunsplit((scheme, netloc, path, query, fragment))
|
||||||
@ -84,7 +84,7 @@ class EmailValidator(RegexValidator):
|
|||||||
if value and '@' in value:
|
if value and '@' in value:
|
||||||
parts = value.split('@')
|
parts = value.split('@')
|
||||||
try:
|
try:
|
||||||
parts[-1] = parts[-1].encode('idna')
|
parts[-1] = parts[-1].encode('idna').decode('ascii')
|
||||||
except UnicodeError:
|
except UnicodeError:
|
||||||
raise e
|
raise e
|
||||||
super(EmailValidator, self).__call__('@'.join(parts))
|
super(EmailValidator, self).__call__('@'.join(parts))
|
||||||
|
@ -143,7 +143,7 @@ def smart_urlquote(url):
|
|||||||
# Handle IDN before quoting.
|
# Handle IDN before quoting.
|
||||||
scheme, netloc, path, query, fragment = urlsplit(url)
|
scheme, netloc, path, query, fragment = urlsplit(url)
|
||||||
try:
|
try:
|
||||||
netloc = netloc.encode('idna') # IDN -> ACE
|
netloc = netloc.encode('idna').decode('ascii') # IDN -> ACE
|
||||||
except UnicodeError: # invalid domain part
|
except UnicodeError: # invalid domain part
|
||||||
pass
|
pass
|
||||||
else:
|
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):
|
elif not ':' in middle and simple_email_re.match(middle):
|
||||||
local, domain = middle.rsplit('@', 1)
|
local, domain = middle.rsplit('@', 1)
|
||||||
try:
|
try:
|
||||||
domain = domain.encode('idna')
|
domain = domain.encode('idna').decode('ascii')
|
||||||
except UnicodeError:
|
except UnicodeError:
|
||||||
continue
|
continue
|
||||||
url = 'mailto:%s@%s' % (local, domain)
|
url = 'mailto:%s@%s' % (local, domain)
|
||||||
|
Loading…
Reference in New Issue
Block a user