mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
fs: fix when path is buffer on fs.symlinkSync
PR-URL: https://github.com/nodejs/node/pull/34540 Fixes: https://github.com/nodejs/node/issues/34514 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Pranshu Srivastava <rexagod@gmail.com>
This commit is contained in:
1 parent
00b9d955e9
commit
9b8596a67f
2 files changed
+6
-1
No files matched your search
@@ -349,6 +349,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.
|
||||
@@ -360,7 +361,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.
|
||||
|
||||
@@ -51,6 +51,10 @@ fs.symlink(linkData, linkPath, common.mustSucceed(() => {
|
||||
fs.readlink(linkPath, common.mustSucceed((destination) => {
|
||||
assert.strictEqual(destination, linkData);
|
||||
}));
|
||||
|
||||
tmpdir.refresh();
|
||||
// Fixes: https://github.com/nodejs/node/issues/34514
|
||||
fs.symlinkSync(Buffer.from(linkData), linkPath);
|
||||
}));
|
||||
|
||||
// Test invalid symlink
|
||||
|
||||
Reference in new issue
Block a user