Commit 96191ca4 by Lu Zhu Committed by GitHub

Fix handling of forward slashes and url encoding in credentials (#1911)

* Add support for forward slashes and url encoding in credentials

* Remove extra newline

* Remove unquote
parent 44c60c4c
...@@ -220,8 +220,8 @@ class LegacyRepository(PyPiRepository): ...@@ -220,8 +220,8 @@ class LegacyRepository(PyPiRepository):
return "{scheme}://{username}:{password}@{netloc}{path}".format( return "{scheme}://{username}:{password}@{netloc}{path}".format(
scheme=parsed.scheme, scheme=parsed.scheme,
username=quote(self._auth.auth.username), username=quote(self._auth.auth.username, safe=""),
password=quote(self._auth.auth.password), password=quote(self._auth.auth.password, safe=""),
netloc=parsed.netloc, netloc=parsed.netloc,
path=parsed.path, path=parsed.path,
) )
......
...@@ -267,7 +267,7 @@ def test_get_package_retrieves_packages_with_no_hashes(): ...@@ -267,7 +267,7 @@ def test_get_package_retrieves_packages_with_no_hashes():
def test_username_password_special_chars(): def test_username_password_special_chars():
auth = Auth("http://foo.bar", "user:", "p@ssword") auth = Auth("http://foo.bar", "user:", "/%2Fp@ssword")
repo = MockRepository(auth=auth) repo = MockRepository(auth=auth)
assert "http://user%3A:p%40ssword@foo.bar" == repo.authenticated_url assert "http://user%3A:%2F%252Fp%40ssword@foo.bar" == repo.authenticated_url
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment