Skip to content

fs: resolve symlinks before parent components - #65457

Draft
jazelly wants to merge 1 commit into
nodejs:mainfrom
jazelly:fix-60295
Draft

jazelly wants to merge 1 commit into
nodejs:mainfrom
jazelly:fix-60295

Conversation

@jazelly

@jazelly jazelly commented Aug 21, 2026

Copy link
Copy Markdown
Member

No description provided.

@nodejs-github-bot nodejs-github-bot added fs Issues and PRs related to file-system APIs and the fs module. needs-ci PRs that need a full CI run. labels Aug 21, 2026
The JavaScript implementation of `fs.realpath()` and
`fs.realpathSync()` joined a symlink target with the rest of the path
through `path.resolve()`, which collapses `..` lexically before the
preceding components have been resolved. A link such as
`d -> c/../d`, where `c` is itself a symlink, was therefore rewritten
back to `d` and the walk never terminated.

Keep `.` and `..` in the path while walking it, and apply `..` to the
already resolved parent, matching `realpath(3)` and
`fs.realpathSync.native()`. Only normalize the final result, and skip
caching link targets containing `..`, whose resolution depends on the
path walked before them.

Fixes: nodejs#60295
Signed-off-by: jazelly <xzha4350@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fs Issues and PRs related to file-system APIs and the fs module. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants