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

Pass revisions options explicitly to mercurial commands #12119

Merged
merged 1 commit into from
Jul 3, 2023
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
Pass revisions options explicitly to mercurial commands
  • Loading branch information
sbidoul committed Jul 1, 2023
commit 45468f06d429080a9042909b76cfc25fce9bee5a
3 changes: 3 additions & 0 deletions news/12119.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Pass the ``-r`` flag to mercurial to be explicit that a revision is passed and protect
against ``hg`` options injection as part of VCS URLs. Users that do not have control on
VCS URLs passed to pip are advised to upgrade.
2 changes: 1 addition & 1 deletion src/pip/_internal/vcs/mercurial.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Mercurial(VersionControl):

@staticmethod
def get_base_rev_args(rev: str) -> List[str]:
return [rev]
return ["-r", rev]

def fetch_new(
self, dest: str, url: HiddenText, rev_options: RevOptions, verbosity: int
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_vcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def test_rev_options_repr() -> None:
# First check VCS-specific RevOptions behavior.
(Bazaar, [], ["-r", "123"], {}),
(Git, ["HEAD"], ["123"], {}),
(Mercurial, [], ["123"], {}),
(Mercurial, [], ["-r", "123"], {}),
(Subversion, [], ["-r", "123"], {}),
# Test extra_args. For this, test using a single VersionControl class.
(
Expand Down