Merge pull request #5158 from node-red/5139-fix-exec-err-encoding

Exec: Make encoding handling consistent between stdout and err
This commit is contained in:
Nick O'Leary
2025-06-06 16:18:33 +01:00
committed by GitHub

View File

@@ -109,7 +109,7 @@ module.exports = function(RED) {
child.stderr.on('data', function (data) {
if (node.activeProcesses.hasOwnProperty(child.pid) && node.activeProcesses[child.pid] !== null) {
if (isUtf8(data)) { msg.payload = data.toString(); }
else { msg.payload = Buffer.from(data); }
else { msg.payload = data; }
nodeSend([null,RED.util.cloneMessage(msg),null]);
}
});
@@ -146,7 +146,8 @@ module.exports = function(RED) {
delete msg.payload;
if (stderr) {
msg2 = RED.util.cloneMessage(msg);
msg2.payload = stderr;
msg2.payload = Buffer.from(stderr,"binary");
if (isUtf8(msg2.payload)) { msg2.payload = msg2.payload.toString(); }
}
msg.payload = Buffer.from(stdout,"binary");
if (isUtf8(msg.payload)) { msg.payload = msg.payload.toString(); }