Commit c7c20d8c by Brian Turek Committed by Sébastien Eustace

Add support for special characters in username/password for pip (#1341)

parent a581ff62
......@@ -21,6 +21,11 @@ from typing import Generator
from typing import Optional
from typing import Union
try:
from urllib.parse import quote
except ImportError:
from urllib import quote
import requests
from cachecontrol import CacheControl
......@@ -197,8 +202,8 @@ class LegacyRepository(PyPiRepository):
return "{scheme}://{username}:{password}@{netloc}{path}".format(
scheme=parsed.scheme,
username=self._auth.auth.username,
password=self._auth.auth.password,
username=quote(self._auth.auth.username),
password=quote(self._auth.auth.password),
netloc=parsed.netloc,
path=parsed.path,
)
......
......@@ -7,6 +7,7 @@ except ImportError:
import urlparse
from poetry.packages import Dependency
from poetry.repositories.auth import Auth
from poetry.repositories.exceptions import PackageNotFound
from poetry.repositories.legacy_repository import LegacyRepository
from poetry.repositories.legacy_repository import Page
......@@ -18,9 +19,9 @@ class MockRepository(LegacyRepository):
FIXTURES = Path(__file__).parent / "fixtures" / "legacy"
def __init__(self):
def __init__(self, auth=None):
super(MockRepository, self).__init__(
"legacy", url="http://foo.bar", disable_cache=True
"legacy", url="http://foo.bar", auth=auth, disable_cache=True
)
def _get(self, endpoint):
......@@ -255,3 +256,10 @@ def test_get_package_retrieves_packages_with_no_hashes():
package = repo.package("jupyter", "1.0.0")
assert [] == package.hashes
def test_username_password_special_chars():
auth = Auth("http://foo.bar", "user:", "p@ssword")
repo = MockRepository(auth=auth)
assert "http://user%3A:p%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