Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Feb 21, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions poetry/repositories/legacy_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@


try:
from urllib.parse import quote
from urllib.parse import quote, unquote
except ImportError:
from urllib import quote
from urllib import quote, unquote


with warnings.catch_warnings():
Expand Down Expand Up @@ -220,8 +220,8 @@ def authenticated_url(self): # type: () -> str

return "{scheme}://{username}:{password}@{netloc}{path}".format(
scheme=parsed.scheme,
username=quote(self._auth.auth.username),
password=quote(self._auth.auth.password),
username=quote(unquote(self._auth.auth.username), safe=""),
password=quote(unquote(self._auth.auth.password), safe=""),
netloc=parsed.netloc,
path=parsed.path,
)
Expand Down
4 changes: 2 additions & 2 deletions tests/repositories/test_legacy_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def test_get_package_retrieves_packages_with_no_hashes():


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)

assert "http://user%3A:p%40ssword@foo.bar" == repo.authenticated_url
assert "http://user%3A:%2F%2Fp%40ssword@foo.bar" == repo.authenticated_url