From 8f26c01f4b0273377f907953098c5288eafa1c07 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Wed, 14 Oct 2015 11:02:31 +0100 Subject: [PATCH] fix escaping of quotes in CSV node --- nodes/core/parsers/70-CSV.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/nodes/core/parsers/70-CSV.js b/nodes/core/parsers/70-CSV.js index 74e6b44e6..8a0295c8f 100644 --- a/nodes/core/parsers/70-CSV.js +++ b/nodes/core/parsers/70-CSV.js @@ -61,11 +61,12 @@ module.exports = function(RED) { var p = RED.util.ensureString(eval("msg.payload[s]."+node.template[t])); if (p === "undefined") { p = ""; } - if (p.indexOf(node.sep) != -1) { // add quotes if any "commas" + if (p.indexOf(node.quo) !== -1) { // add double quotes if any quotes + console.log("ping"); + p = p.replace(/"/g, '""'); ou += node.quo + p + node.quo + node.sep; } - else if (p.indexOf(node.quo) != -1) { // add double quotes if any quotes - p = p.replace(/"/g, '""'); + else if (p.indexOf(node.sep) !== -1) { // add quotes if any "commas" ou += node.quo + p + node.quo + node.sep; } else { ou += p + node.sep; } // otherwise just add