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

Fix #4615 - Improve sanitization to allow virtualenv paths with () and [] characters to activate #4616

Merged
merged 3 commits into from
Mar 16, 2021
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
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]
leohku marked this conversation as resolved.
Show resolved Hide resolved

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