Skip to content

Commit

Permalink
Fixed writeValues not handling new lines
Browse files Browse the repository at this point in the history
  • Loading branch information
chriso committed May 19, 2011
1 parent 9c96976 commit 65c2d14
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions lib/node.io/io.js
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion 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 <cohara87@gmail.com>",
Expand Down

0 comments on commit 65c2d14

Please sign in to comment.