Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

cope with unsplittable urls in smarl_urlquote.

  • Loading branch information...
commit 74809fdcc75c400e7d2eac4fa1b0f4113f9f395b 1 parent 161cafb
@tominsam tominsam authored
Showing with 9 additions and 5 deletions.
  1. +9 −5 django/utils/html.py
View
14 django/utils/html.py
@@ -150,13 +150,17 @@ def fix_ampersands(value):
def smart_urlquote(url):
"Quotes a URL if it isn't already quoted."
# Handle IDN before quoting.
- scheme, netloc, path, query, fragment = urlsplit(url)
try:
- netloc = netloc.encode('idna').decode('ascii') # IDN -> ACE
- except UnicodeError: # invalid domain part
+ scheme, netloc, path, query, fragment = urlsplit(url)
+ try:
+ netloc = netloc.encode('idna').decode('ascii') # IDN -> ACE
+ except UnicodeError: # invalid domain part
+ pass
+ else:
+ url = urlunsplit((scheme, netloc, path, query, fragment))
+ except ValueError:
+ # invalid IPv6 URL (normally square brackets in hostname part).
pass
- else:
- url = urlunsplit((scheme, netloc, path, query, fragment))
# An URL is considered unquoted if it contains no % characters or
# contains a % not followed by two hexadecimal digits. See #9655.
Please sign in to comment.
Something went wrong with that request. Please try again.