1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00

Merge pull request #6440 from nicolasbock/index_with_git

Protect `@` as safe character when cleaning URLs
This commit is contained in:
Chris Jerdonek 2019-04-25 13:28:48 -07:00 committed by GitHub
commit 60d3f11961
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 2 deletions

2
news/6440.bugfix Normal file
View file

@ -0,0 +1,2 @@
Fix a regression that caused `@` to be quoted in pypiserver links.
This interfered with parsing the revision string from VCS urls.

View file

@ -336,6 +336,7 @@ class FoundCandidates(object):
* `evaluator`: A CandidateEvaluator object to sort applicable candidates * `evaluator`: A CandidateEvaluator object to sort applicable candidates
by order of preference. by order of preference.
""" """
def __init__( def __init__(
self, self,
candidates, # type: List[InstallationCandidate] candidates, # type: List[InstallationCandidate]
@ -1061,7 +1062,9 @@ def _clean_link(url):
path = urllib_request.pathname2url( path = urllib_request.pathname2url(
urllib_request.url2pathname(result.path)) urllib_request.url2pathname(result.path))
else: else:
path = urllib_parse.quote(urllib_parse.unquote(result.path)) # In addition to the `/` character we protect `@` so that
# revision strings in VCS URLs are properly parsed.
path = urllib_parse.quote(urllib_parse.unquote(result.path), safe="/@")
return urllib_parse.urlunparse(result._replace(path=path)) return urllib_parse.urlunparse(result._replace(path=path))

View file

@ -308,7 +308,10 @@ def test_request_retries(caplog):
# URL with something that looks like a drive letter, but is # URL with something that looks like a drive letter, but is
# not. The `:` should be quoted. # not. The `:` should be quoted.
("https://localhost.localdomain/T:/path/", ("https://localhost.localdomain/T:/path/",
"https://localhost.localdomain/T%3A/path/") "https://localhost.localdomain/T%3A/path/"),
# VCS URL containing revision string.
("git+ssh://example.com/path to/repo.git@1.0#egg=my-package-1.0",
"git+ssh://example.com/path%20to/repo.git@1.0#egg=my-package-1.0")
] ]
) )
def test_clean_link(url, clean_url): def test_clean_link(url, clean_url):