Skip to content

Commit d694c00

Browse files
Fix URL handling that can lead to silent failures
1 parent 98576dc commit d694c00

File tree

1 file changed

+7
-2
lines changed
  • packages/pyodide-kernel/py/piplite/piplite

1 file changed

+7
-2
lines changed

packages/pyodide-kernel/py/piplite/piplite/cli.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ def add_requirement(self, req: str):
5050

5151

5252
REQ_FILE_PREFIX = r"^(-r|--requirements)\s*=?\s*(.*)\s*"
53-
INDEX_URL_PREFIX = r"^(--index-url|-i)\s*=?\s*(.*)\s*"
53+
54+
# Matches a pip-style index URL, with support for quote enclosures
55+
INDEX_URL_PREFIX = (
56+
r'^(--index-url|-i)\s*=?\s*(?:"([^"]*)"|\047([^\047]*)\047|([^\s]*))\s*$'
57+
)
5458

5559

5660
__all__ = ["get_transformed_code"]
@@ -259,7 +263,8 @@ async def _packages_from_requirements_line(
259263
# Check for index URL - this becomes the new active index URL.
260264
index_match = re.match(INDEX_URL_PREFIX, req)
261265
if index_match:
262-
context.index_url = index_match[2].strip()
266+
url = next(group for group in index_match.groups()[1:] if group is not None)
267+
context.index_url = url.strip()
263268
return
264269

265270
if req.startswith("-"):

0 commit comments

Comments
 (0)