Skip to content

Fix POSIX backslash anchor normalization - #9

Merged
krishika08 merged 1 commit into
mainfrom
fix/posix-anchor-backslash
Nov 10, 2026
Merged

krishika08 merged 1 commit into
mainfrom
fix/posix-anchor-backslash

Conversation

@krishika08

Copy link
Copy Markdown
Owner

Summary

Follow-up to the merged PR #8. It adds the fix commit (8e19fde), which was pushed to feat/cli-json-anchor-support after #8 had already merged. That commit therefore never reached main and never went through the pull-request CI checks. It is cherry-picked here unchanged onto current main.

Problem

On Linux and macOS, reponeedle --anchors 'src\payment.py' failed with "does not exist or is not a regular file". resolve_and_validate_anchors() looked for a file literally named src\payment.py. The Python API (retrieve(anchor_files=...)) already converts backslashes to forward slashes, so the CLI and the API behaved differently.

This caused the one failure in each Production CI matrix job on PR #8 (test_resolve_and_validate_anchors_normalization, Python 3.10, 3.11 and 3.12). The same failure is therefore expected on main now.

Fix (reponeedle/cli.py)

  • The exact spelling is tried first.
  • Only on POSIX (os.sep == "/"), and only if the anchor contains a backslash, the forward-slash spelling is tried next.
  • A real file whose name contains a backslash still takes precedence.
  • All existing containment checks run unchanged on whichever file is resolved:
    • the component-aware .. traversal check;
    • the drive check;
    • canonical symlink and junction containment.

Tests (tests/test_cli_anchors.py)

  • New: test_resolve_and_validate_anchors_backslash_traversal_rejected. ..\outside_bs.py (a real file just outside the repository) must still be rejected with "resolves outside repository root".
  • The existing test_resolve_and_validate_anchors_normalization covers src\payment.py → src/payment.py.

Verification

Check Result
Diff against main Only reponeedle/cli.py and tests/test_cli_anchors.py (+24/−8)
Anchor, CLI JSON, indexing-security and MCP suites (Windows, Python 3.12) 55 passed, 7 skipped (symlink creation is not permitted on this Windows host; covered by mcp-security-linux)
Simulated POSIX path semantics main: src\payment.py rejected (reproduces the CI failure). This branch: resolves to src/payment.py; ..\outside.py rejected
Package version 1.1.0 (unchanged)

Real POSIX confirmation comes from this PR's Linux CI jobs.

No version bump, tag or publication.

🤖 Generated with Claude Code

resolve_and_validate_anchors() looked up 'src\payment.py' literally on
Linux and rejected it, while retrieve(anchor_files=...) already
normalizes backslashes. Try the exact spelling first, then (POSIX only)
the forward-slash spelling. All containment checks still apply to the
resolved file. Add a test that '..\outside.py' is still rejected.

Fixes test_resolve_and_validate_anchors_normalization on Linux CI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@krishika08
krishika08 merged commit 0fa3676 into main Nov 10, 2026
5 checks passed
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.

1 participant