Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fs: fix when path is buffer #34540

Closed
wants to merge 3 commits into from
Closed
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
3 changes: 2 additions & 1 deletion lib/internal/fs/utils.js
Original file line number Diff line number Diff line change
@@ -336,6 +336,7 @@ function preprocessSymlinkDestination(path, type, linkPath) {
// No preprocessing is needed on Unix.
return path;
}
path = '' + path;
if (type === 'junction') {
// Junctions paths need to be absolute and \\?\-prefixed.
// A relative target is relative to the link's parent directory.
@@ -347,7 +348,7 @@ function preprocessSymlinkDestination(path, type, linkPath) {
return pathModule.toNamespacedPath(path);
}
// Windows symlinks don't tolerate forward slashes.
return ('' + path).replace(/\//g, '\\');
return path.replace(/\//g, '\\');
}

// Constructor for file stats.
4 changes: 4 additions & 0 deletions test/parallel/test-fs-symlink.js
Original file line number Diff line number Diff line change
@@ -56,6 +56,10 @@ fs.symlink(linkData, linkPath, common.mustCall(function(err) {
assert.ifError(err);
assert.strictEqual(destination, linkData);
}));

tmpdir.refresh();
// Fixes: https://github.com/nodejs/node/issues/34514
fs.symlinkSync(Buffer.from(linkData), linkPath);
}));

// Test invalid symlink