1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

fix escaping of quotes in CSV node

This commit is contained in:
Dave Conway-Jones 2015-10-14 11:02:31 +01:00
parent 61045ddd7f
commit 8f26c01f4b

View File

@ -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