Commit 74809fdc authored by Tom Insam's avatar Tom Insam
Browse files

cope with unsplittable urls in smarl_urlquote.

parent 161cafb6
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -150,6 +150,7 @@ fix_ampersands = allow_lazy(fix_ampersands, six.text_type)
def smart_urlquote(url):
    "Quotes a URL if it isn't already quoted."
    # Handle IDN before quoting.
    try:
        scheme, netloc, path, query, fragment = urlsplit(url)
        try:
            netloc = netloc.encode('idna').decode('ascii') # IDN -> ACE
@@ -157,6 +158,9 @@ def smart_urlquote(url):
            pass
        else:
            url = urlunsplit((scheme, netloc, path, query, fragment))
    except ValueError:
        # invalid IPv6 URL (normally square brackets in hostname part).
        pass

    # An URL is considered unquoted if it contains no % characters or
    # contains a % not followed by two hexadecimal digits. See #9655.