Repository navigation
test(docs): refuse a citation through a symlink that leaves the checkout (#1282) - #1285
Merged
Merged
Conversation
Red first: a committed symlink to a file outside the checkout is still followed, so an in-range citation reports nothing and a past-the-end one reports the outside file's length.
Resolve the cited path and require it to stay under the checkout root before is_file() or a line count, so a committed symlink to an outside file is reported as an escape rather than verified against a file this repository does not contain.
Collaborator
Author
|
Review (Birfy) Tip SHA: 4208b59
|
Birfy
enabled auto-merge (squash)
November 25, 2026 16:30
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1282.
What changed
Before:
tests/test_docs_citations.pydecided containment lexically (..in the path, or an absolute path) and then calledis_file()/_line_count()onroot / path. A committed symlink at that leaf is neither..nor absolute, so the guard followed it and line-counted a file this repository does not contain. An in-range citation reported nothing (the page read as verified); a past-the-end one reported the outside file's length.After: after the lexical checks, the guard resolves the cited path and requires it to stay under
root.resolve()before anyis_file()or line count. An escaping link is reported as(citation path escapes this repository), the same message as#988/ the..and absolute cases.The shipped docs are untouched. Tests-only plus the guard in the test module — no
docs/or runtime change, so no changelog fragment (changelog_fragments checkpasses without one).Verification at the tip
Tip SHA: 4208b59
Red at
48fdc67889with only the test delta (6629fddb97):Ran:
python -m pytest tests/test_docs_citations.py -q→7 passed in 0.10spython -m pytest tests/test_docs_citations.py tests/test_docs_links.py tests/test_site_navigation.py tests/test_docs_examples.py -q→38 passed in 7.92spython -m tools.changelog_fragments check→47 changelog fragment(s) OKpython -m tools.gen_api_docs --check→docs/api.md is up to dateNot run:
pytest -q— the delta is one test file, the docs family above is the affected surface.mkdocs build --strict— no page, nav or mkdocs.yml change.