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

Protect @ as safe character when cleaning URLs #6440

Merged
merged 1 commit into from
Apr 25, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions news/6440.bugfix
Original file line number Diff line number Diff line change
@@ -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.
5 changes: 4 additions & 1 deletion src/pip/_internal/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ class FoundCandidates(object):
* `evaluator`: A CandidateEvaluator object to sort applicable candidates
by order of preference.
"""

def __init__(
self,
candidates, # type: List[InstallationCandidate]
Expand Down Expand Up @@ -1061,7 +1062,9 @@ def _clean_link(url):
path = urllib_request.pathname2url(
urllib_request.url2pathname(result.path))
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="/@")
nicolasbock marked this conversation as resolved.
Show resolved Hide resolved
return urllib_parse.urlunparse(result._replace(path=path))


Expand Down
5 changes: 4 additions & 1 deletion tests/unit/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,10 @@ def test_request_retries(caplog):
# URL with something that looks like a drive letter, but is
# not. The `:` should be quoted.
("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/[email protected]#egg=my-package-1.0",
"git+ssh://example.com/path%20to/[email protected]#egg=my-package-1.0")
]
)
def test_clean_link(url, clean_url):
Expand Down