Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

cope with unsplittable urls in smarl_urlquote.

  • Loading branch information...
commit 74809fdcc75c400e7d2eac4fa1b0f4113f9f395b 1 parent 161cafb
Tom Insam authored December 03, 2012

Showing 1 changed file with 9 additions and 5 deletions. Show diff stats Hide diff stats

  1. 14  django/utils/html.py
14  django/utils/html.py
@@ -150,13 +150,17 @@ def fix_ampersands(value):
150 150
 def smart_urlquote(url):
151 151
     "Quotes a URL if it isn't already quoted."
152 152
     # Handle IDN before quoting.
153  
-    scheme, netloc, path, query, fragment = urlsplit(url)
154 153
     try:
155  
-        netloc = netloc.encode('idna').decode('ascii') # IDN -> ACE
156  
-    except UnicodeError: # invalid domain part
  154
+        scheme, netloc, path, query, fragment = urlsplit(url)
  155
+        try:
  156
+            netloc = netloc.encode('idna').decode('ascii') # IDN -> ACE
  157
+        except UnicodeError: # invalid domain part
  158
+            pass
  159
+        else:
  160
+            url = urlunsplit((scheme, netloc, path, query, fragment))
  161
+    except ValueError:
  162
+        # invalid IPv6 URL (normally square brackets in hostname part).
157 163
         pass
158  
-    else:
159  
-        url = urlunsplit((scheme, netloc, path, query, fragment))
160 164
 
161 165
     # An URL is considered unquoted if it contains no % characters or
162 166
     # contains a % not followed by two hexadecimal digits. See #9655.

0 notes on commit 74809fd

Please sign in to comment.
Something went wrong with that request. Please try again.