From adebdf36a5458356d59c260c5e242cf453deb47c Mon Sep 17 00:00:00 2001 From: Simon Asp Date: Sun, 18 Jun 2017 12:55:39 +0200 Subject: [PATCH] Bug fix in exec node. White spaces in arguments now works (#1285) --- nodes/core/core/75-exec.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/nodes/core/core/75-exec.js b/nodes/core/core/75-exec.js index 8205edfef..8bfc16fcd 100644 --- a/nodes/core/core/75-exec.js +++ b/nodes/core/core/75-exec.js @@ -46,10 +46,11 @@ module.exports = function(RED) { var arg = node.cmd; if ((node.addpay === true) && msg.hasOwnProperty("payload")) { arg += " "+msg.payload; } if (node.append.trim() !== "") { arg += " "+node.append; } - // slice whole line by spaces (trying to honour quotes); - arg = arg.match(/(?:[^\s"]+|"[^"]*")+/g); + // slice whole line by spaces and removes any quotes since spawn can't handle them + arg = arg.match(/(?:[^\s"]+|"[^"]*")+/g).map((a) => { + if (/^".*"$/.test(a)) { return a.slice(1,-1)} else {return a}; + }); var cmd = arg.shift(); - if (/^".*"$/.test(cmd)) { cmd = cmd.slice(1,-1); } /* istanbul ignore else */ if (RED.settings.verbose) { node.log(cmd+" ["+arg+"]"); } child = spawn(cmd,arg);