Skip to content

Commit

Permalink
Escape command line requirements as necessary
Browse files Browse the repository at this point in the history
- Fixes #2998

Signed-off-by: Dan Ryan <[email protected]>
  • Loading branch information
techalchemy committed Oct 11, 2018
1 parent 485da19 commit 12e80ed
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions news/2998.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed a bug which prevented installing pinned versions which used redirection symbols from the command line.
2 changes: 2 additions & 0 deletions pipenv/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
rmtree,
clean_resolved_dep,
parse_indexes,
escape_cmd
)
from . import environments, pep508checker, progress
from .environments import (
Expand Down Expand Up @@ -1398,6 +1399,7 @@ def pip_install(
pip_command.append("--upgrade-strategy=only-if-needed")
if no_deps:
pip_command.append("--no-deps")
install_reqs = [escape_cmd(req) for req in install_reqs]
pip_command.extend(install_reqs)
pip_command.extend(prepare_pip_source_args(sources))
if not ignore_hashes:
Expand Down
6 changes: 6 additions & 0 deletions pipenv/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1048,6 +1048,12 @@ def handle_remove_readonly(func, path, exc):
raise


def escape_cmd(cmd):
if any(special_char in cmd for special_char in ["<", ">", "&", ".", "^", "|", "?"]):
cmd = '\'{0}\''.format(cmd)
return cmd


@contextmanager
def atomic_open_for_write(target, binary=False, newline=None, encoding=None):
"""Atomically open `target` for writing.
Expand Down

0 comments on commit 12e80ed

Please sign in to comment.