From 12e80edede0e61e2ea19c132570862d25e4368fe Mon Sep 17 00:00:00 2001 From: Dan Ryan Date: Thu, 11 Oct 2018 12:35:27 -0400 Subject: [PATCH] Escape command line requirements as necessary - Fixes #2998 Signed-off-by: Dan Ryan --- news/2998.bugfix | 1 + pipenv/core.py | 2 ++ pipenv/utils.py | 6 ++++++ 3 files changed, 9 insertions(+) create mode 100644 news/2998.bugfix diff --git a/news/2998.bugfix b/news/2998.bugfix new file mode 100644 index 00000000..fd9c5d8c --- /dev/null +++ b/news/2998.bugfix @@ -0,0 +1 @@ +Fixed a bug which prevented installing pinned versions which used redirection symbols from the command line. diff --git a/pipenv/core.py b/pipenv/core.py index eb42c5e7..7633bdfc 100644 --- a/pipenv/core.py +++ b/pipenv/core.py @@ -40,6 +40,7 @@ from .utils import ( rmtree, clean_resolved_dep, parse_indexes, + escape_cmd ) from . import environments, pep508checker, progress from .environments import ( @@ -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: diff --git a/pipenv/utils.py b/pipenv/utils.py index f3599301..e4f55fbb 100644 --- a/pipenv/utils.py +++ b/pipenv/utils.py @@ -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.