Skip to content

Commit

Permalink
Percent-encode invalid characters within auth section (#1647)
Browse files Browse the repository at this point in the history
  • Loading branch information
sethmlarson committed Jul 26, 2019
1 parent 15acc9f commit 5b047b6
Show file tree
Hide file tree
Showing 22 changed files with 348 additions and 2,869 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Expand Up @@ -9,6 +9,11 @@ dev (master)
* Fix edge case where Retry-After header was still respected even when
explicitly opted out of. (Pull #1607)

* Remove dependency on ``rfc3986`` for URL parsing.

* Fix issue where URLs containing invalid characters within ``Url.auth`` would
raise an exception instead of percent-encoding those characters.


1.25.3 (2019-05-23)
-------------------
Expand Down
4 changes: 2 additions & 2 deletions _travis/upload_coverage.sh
Expand Up @@ -3,6 +3,6 @@
set -exo pipefail

if [[ -e .coverage ]]; then
python3.6 -m pip install codecov
python3.6 -m codecov --env TRAVIS_OS_NAME,NOX_SESSION
python3 -m pip install codecov
python3 -m codecov --env TRAVIS_OS_NAME,NOX_SESSION
fi
2 changes: 2 additions & 0 deletions noxfile.py
Expand Up @@ -77,6 +77,8 @@ def blacken(session):
session.install("black")
session.run("black", "src", "dummyserver", "test", "noxfile.py", "setup.py")

lint(session)


@nox.session
def lint(session):
Expand Down
1 change: 0 additions & 1 deletion setup.py
Expand Up @@ -57,7 +57,6 @@
"urllib3.packages",
"urllib3.packages.ssl_match_hostname",
"urllib3.packages.backports",
"urllib3.packages.rfc3986",
"urllib3.contrib",
"urllib3.contrib._securetransport",
"urllib3.util",
Expand Down
9 changes: 4 additions & 5 deletions src/urllib3/connectionpool.py
Expand Up @@ -26,7 +26,6 @@
from .packages.ssl_match_hostname import CertificateError
from .packages import six
from .packages.six.moves import queue
from .packages.rfc3986.normalizers import normalize_host
from .connection import (
port_by_scheme,
DummyConnection,
Expand All @@ -44,7 +43,7 @@
from .util.response import assert_header_parsing
from .util.retry import Retry
from .util.timeout import Timeout
from .util.url import get_host, Url, NORMALIZABLE_SCHEMES
from .util.url import get_host, Url, _normalize_host as normalize_host
from .util.queue import LifoQueue


Expand Down Expand Up @@ -1027,14 +1026,14 @@ def _normalize_host(host, scheme):
Normalize hosts for comparisons and use with sockets.
"""

host = normalize_host(host, scheme)

# httplib doesn't like it when we include brackets in IPv6 addresses
# Specifically, if we include brackets but also pass the port then
# httplib crazily doubles up the square brackets on the Host header.
# Instead, we need to make sure we never pass ``None`` as the port.
# However, for backward compatibility reasons we can't actually
# *assert* that. See http://bugs.python.org/issue28539
if host.startswith("[") and host.endswith("]"):
host = host.strip("[]")
if scheme in NORMALIZABLE_SCHEMES:
host = normalize_host(host)
host = host[1:-1]
return host
56 changes: 0 additions & 56 deletions src/urllib3/packages/rfc3986/__init__.py

This file was deleted.

0 comments on commit 5b047b6

Please sign in to comment.