From 65c2d14ddbccb4e759e1d17a3d962eac4b0198d1 Mon Sep 17 00:00:00 2001 From: Chris O'Hara Date: Thu, 19 May 2011 19:31:13 +1000 Subject: [PATCH] Fixed writeValues not handling new lines --- lib/node.io/io.js | 7 +++++-- package.json | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/node.io/io.js b/lib/node.io/io.js index c9eecc2..6dce11a 100755 --- a/lib/node.io/io.js +++ b/lib/node.io/io.js @@ -569,12 +569,15 @@ Job.prototype.writeValues = function(values, delim, quote, quote_escape) { quote_escape = quote_escape || '"'; if (values instanceof Array) { - var quoted_values = [], value, quote_reg = new RegExp('[' + quote + ']', 'g'); + var quoted_values = [], value, + quote_reg = new RegExp('[' + quote + ']', 'g'), + requires_quotes = new RegExp('[' + delim + '\r\n]'); + for (var i = 0, l = values.length; i < l; i++) { value = values[i] == null ? '' : '' + values[i]; if (value && value.indexOf(quote) > -1) { value = quote + value.replace(quote_reg, quote_escape + quote) + quote; - } else if (value == '' || value.indexOf(delim) > -1) { + } else if (value == '' || requires_quotes.test(value)) { value = quote + value + quote; } quoted_values.push(value); diff --git a/package.json b/package.json index fa3e39a..0d9b07f 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name" : "node.io", "description" : "A distributed data scraping and processing framework", - "version" : "0.2.9-2", + "version" : "0.2.9-3", "homepage" : "http://github.com/chriso/node.io", "keywords" : ["data","mapreduce","map","reduce","scraping","html","parsing","parse","scrape","process","processing","data"], "author" : "Chris O'Hara ",