From 7ef418ec52a2cff82161b0b581b3c91aaa4695ca Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Tue, 27 Feb 2018 13:05:10 +0000 Subject: [PATCH] Ensure sshkey file path is properly escaped on Windows --- red/runtime/storage/localfilesystem/projects/ssh/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/red/runtime/storage/localfilesystem/projects/ssh/index.js b/red/runtime/storage/localfilesystem/projects/ssh/index.js index 4188b07ce..dd65379cb 100644 --- a/red/runtime/storage/localfilesystem/projects/ssh/index.js +++ b/red/runtime/storage/localfilesystem/projects/ssh/index.js @@ -187,16 +187,18 @@ function getPrivateKeyPath(username, name) { var privateKeyFilePath = fspath.normalize(fspath.join(sshkeyDir, sshKeyFileBasename)); try { fs.accessSync(privateKeyFilePath, (fs.constants || fs).R_OK); - return privateKeyFilePath; } catch(err) { privateKeyFilePath = fspath.join(userSSHKeyDir,name); try { fs.accessSync(privateKeyFilePath, (fs.constants || fs).R_OK); - return privateKeyFilePath; } catch(err2) { return null; } } + if (fspath.sep === '\\') { + privateKeyFilePath = privateKeyFilePath.replace(/\\/g,'\\\\'); + } + return privateKeyFilePath; } module.exports = {