Skip to content

localRealpath follows a link target's .. after the links before it - #6

Merged
nedtwigg merged 1 commit into
mainfrom
link-target-dotdot
Dec 4, 2026
Merged

nedtwigg merged 1 commit into
mainfrom
link-target-dotdot

Conversation

@nedtwigg

@nedtwigg nedtwigg commented Dec 3, 2026

Copy link
Copy Markdown
Member

localRealpath (@dor-tools/scaffold/server) collapsed a .. in a symlink's target lexically before walking it. For a -> b/.. where b is itself a link, it answered a's directory, while opening a goes to the parent of wherever b leads. The walk now keeps a target's .. as a component and applies it, as the filesystem does, to the link-free path walked so far, so the answer is where the kernel goes. A rooted target is walked from its drive's root.

The folder Tool's compaction now lists each hop by the canonical path it checked to be inside the root, the same as existingInside and kindOf already do, rather than passing the uncanonical path to opendir.

Verified:

  • scaffold/test/local-path.test.mjs: a Windows-semantics case (relative and rooted targets whose .. follows a link) and a real POSIX case comparing against the kernel. Both fail with the walk change reverted.
  • suite/test/folder-viewer.test.mjs: a link whose target's .. leaves through another link lists as other and cannot be listed. Fails with the scaffold change reverted.
  • pnpm test in scaffold (22 pass) and suite (270 pass).

🤖 Generated with Claude Code

A symlink target such as `b/..` was collapsed lexically before `b` was
looked at, so when `b` was itself a link the walk answered a different
path than opening the link reaches. The walk now keeps a target's `..`
as a component and applies it to the link-free path walked so far.

The folder Tool also lists a compacted folder by the canonical path it
checked to be inside its root, rather than handing the kernel the
uncanonical one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying dor-tools with  Cloudflare Pages  Cloudflare Pages

Latest commit: d02d0a9
Status: ✅  Deploy successful!
Preview URL: https://7df3fbaa.dor-tools.pages.dev
Branch Preview URL: https://link-target-dotdot.dor-tools.pages.dev

View logs

@nedtwigg
nedtwigg merged commit d0d769b into main Dec 4, 2026
6 of 7 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