Skip to content

fix(direct_url): reject out-of-root subdirectory paths - #1348

Open
r266-tech wants to merge 1 commit into
pypa:mainfrom
r266-tech:fix/direct-url-subdirectory-containment
Open

fix(direct_url): reject out-of-root subdirectory paths#1348
r266-tech wants to merge 1 commit into
pypa:mainfrom
r266-tech:fix/direct-url-subdirectory-containment

Conversation

@r266-tech

Copy link
Copy Markdown
Contributor

Summary

  • enforce the Direct URL specification's requirement that subdirectory remain relative to the referenced source root
  • reject POSIX absolute, Windows rooted/drive/UNC, and parent-traversal paths with one platform-independent lexical check
  • preserve valid relative strings unchanged and keep validation at from_dict() / validate() rather than dataclass construction

Tests

  • uv run --group test pytest -q (62414 passed, 1 skipped, 427 deselected)
  • uv run --group test pytest tests/test_direct_url.py -q (66 passed)
  • uv run ruff check src/packaging/direct_url.py tests/test_direct_url.py
  • uv run ruff format --check src/packaging/direct_url.py tests/test_direct_url.py
  • git diff --check

@henryiii
henryiii requested a review from sbidoul July 22, 2026 18:56
@sbidoul

sbidoul commented Jul 25, 2026

Copy link
Copy Markdown
Member

I'm not convinced this is in scope for packaging. I tend to say no, since we rejected similar things in the pylock area.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants