Skip to content
Draft
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
2 changes: 1 addition & 1 deletion src/conductor/executor/linkify.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def _try_linkify_path(token: str, base_dir: Path | None) -> str | None:
if base_dir is not None:
try:
resolved_base = base_dir.resolve()
candidate = (base_dir / stripped).resolve()
candidate = (base_dir / normalized).resolve()
# Security: must be within base_dir (path-aware containment, not
# string-prefix — `/foo/bar` must not match `/foo/barbaz/...`).
if not candidate.is_relative_to(resolved_base):
Expand Down
7 changes: 7 additions & 0 deletions tests/test_executor/test_linkify.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ def test_nested_path(self, tmp_path: Path) -> None:
result = linkify_markdown("Plan at docs/projects/plan.md", base_dir=tmp_path)
assert "[docs/projects/plan.md](docs/projects/plan.md)" in result

def test_windows_relative_path_separator(self, tmp_path: Path) -> None:
(tmp_path / "docs").mkdir()
(tmp_path / "docs" / "readme.md").write_text("hello")

result = linkify_markdown(r"See docs\readme.md for details", base_dir=tmp_path)
assert r"[docs\readme.md](docs/readme.md)" in result

def test_nonexistent_file_not_linked(self, tmp_path: Path) -> None:
result = linkify_markdown("See docs/missing.md for details", base_dir=tmp_path)
assert "[docs/missing.md]" not in result
Expand Down