Skip to content

Commit a78cad8

Browse files
authored
Try to match if the part after @ is a valid ref (reject treating URL parts as refs). (#5856)
* Try to match ref only if the part after @ is a valid ref (reject treating URL parts as refs).
1 parent 0501f9b commit a78cad8

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

news/5849.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
More gracefully handle @ symbols in vcs URLs to address recent regression with vcs URLs.

pipenv/utils/dependencies.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -981,8 +981,9 @@ def install_req_from_pipfile(name, pipfile):
981981
"ssh://" not in vcs_url and "@" in vcs_url
982982
):
983983
vcs_url_parts = vcs_url.rsplit("@", 1)
984-
vcs_url = vcs_url_parts[0]
985-
fallback_ref = vcs_url_parts[1]
984+
if re.match(r"^[\w\.]+$", vcs_url_parts[1]):
985+
vcs_url = vcs_url_parts[0]
986+
fallback_ref = vcs_url_parts[1]
986987
req_str = f"{vcs_url}@{_pipfile.get('ref', fallback_ref)}{extras_str}"
987988
if not req_str.startswith(f"{vcs}+"):
988989
req_str = f"{vcs}+{req_str}"

pipenv/utils/requirements.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,11 @@ def requirement_from_lockfile(
160160
"ssh://" not in url and "@" in url
161161
):
162162
url_parts = url.rsplit("@", 1)
163-
url = url_parts[0]
164-
if not ref:
165-
ref = url_parts[1]
163+
# Check if the second part matches the criteria to be a ref (vcs URLs would likely have a /)
164+
if re.match(r"^[\w\.]+$", url_parts[1]):
165+
url = url_parts[0]
166+
if not ref:
167+
ref = url_parts[1]
166168

167169
extras = (
168170
"[{}]".format(",".join(package_info.get("extras", [])))

0 commit comments

Comments
 (0)