Skip to content

Commit

Permalink
Merge pull request #4616 from leohku/4615-fix
Browse files Browse the repository at this point in the history
Fix #4615 - Improve sanitization to allow virtualenv paths with () and [] characters to activate
  • Loading branch information
frostming authored Mar 16, 2021
2 parents 76ce63c + 470ef3a commit 275f7e1
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions news/4615.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix bug where environment wouldn't activate in paths containing () and [] symbols
2 changes: 1 addition & 1 deletion pipenv/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pipenv/shells.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 275f7e1

Please sign in to comment.