From 19fc5386db72ca52e0412b63475e1e562d31e6f6 Mon Sep 17 00:00:00 2001 From: Leo Ho Date: Sun, 7 Feb 2021 14:51:35 +0800 Subject: [PATCH 1/2] Fix regex escaping bug in activation path --- news/4615.bugfix.rst | 1 + pipenv/project.py | 2 +- pipenv/shells.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 news/4615.bugfix.rst diff --git a/news/4615.bugfix.rst b/news/4615.bugfix.rst new file mode 100644 index 0000000000..bdac52e66d --- /dev/null +++ b/news/4615.bugfix.rst @@ -0,0 +1 @@ +Fix bug where environment wouldn't activate in paths containing () and [] symbols - Related to #4538 diff --git a/pipenv/project.py b/pipenv/project.py index 90ff16fbce..9709609faa 100644 --- a/pipenv/project.py +++ b/pipenv/project.py @@ -395,7 +395,7 @@ def _sanitize(cls, name): # https://www.gnu.org/software/bash/manual/html_node/Double-Quotes.html # http://www.tldp.org/LDP/abs/html/special-chars.html#FIELDREF # https://github.com/torvalds/linux/blob/2bfe01ef/include/uapi/linux/binfmts.h#L18 - return re.sub(r'[ &$`!*@"\\\r\n\t]', "_", name)[0:42] + return re.sub(r'[ &$`!*@"()\[\]\\\r\n\t]', "_", name)[0:42] def _get_virtualenv_hash(self, name): # type: (str) -> str diff --git a/pipenv/shells.py b/pipenv/shells.py index 5a9aae2abc..af3b0c03bf 100644 --- a/pipenv/shells.py +++ b/pipenv/shells.py @@ -50,7 +50,7 @@ def _get_activate_script(cmd, venv): command = "." # Escape any special characters located within the virtualenv path to allow # for proper activation. - venv_location = re.sub(r'([ &$])', r"\\\1", str(venv)) + venv_location = re.sub(r'([ &$()\[\]])', r"\\\1", str(venv)) # The leading space can make history cleaner in some shells. return " {2} {0}/bin/activate{1}".format(venv_location, suffix, command) From a8ffd3067824089120c9dbbe8b4b3e29196788c4 Mon Sep 17 00:00:00 2001 From: Leo Ho Date: Sun, 7 Feb 2021 15:10:11 +0800 Subject: [PATCH 2/2] Modify news fragment --- news/4615.bugfix.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/news/4615.bugfix.rst b/news/4615.bugfix.rst index bdac52e66d..033e6b4445 100644 --- a/news/4615.bugfix.rst +++ b/news/4615.bugfix.rst @@ -1 +1 @@ -Fix bug where environment wouldn't activate in paths containing () and [] symbols - Related to #4538 +Fix bug where environment wouldn't activate in paths containing () and [] symbols