From 69eeb71df6afb2ebd7ae174d3bf275bdefedad51 Mon Sep 17 00:00:00 2001 From: Braden Anderson Date: Thu, 23 Jul 2015 11:54:24 -0600 Subject: [PATCH] handle empty quoted field at EOF --- papaparse.js | 2 +- tests/test-cases.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/papaparse.js b/papaparse.js index 958d0ac..c3c1f48 100644 --- a/papaparse.js +++ b/papaparse.js @@ -1201,7 +1201,7 @@ { if (ignoreLastRow) return returnable(); - if (!value) + if (typeof value === 'undefined') value = input.substr(cursor); row.push(value); cursor = inputLen; // important in case parsing is paused diff --git a/tests/test-cases.js b/tests/test-cases.js index 48ee0c8..cbd7a1c 100644 --- a/tests/test-cases.js +++ b/tests/test-cases.js @@ -219,6 +219,14 @@ var CORE_PARSER_TESTS = [ errors: [] } }, + { + description: "Empty quoted field at EOF is empty", + input: 'a,b,""\na,b,""', + expected: { + data: [['a', 'b', ''], ['a', 'b', '']], + errors: [] + } + }, { description: "Multiple consecutive empty fields", input: 'a,b,,,c,d\n,,e,,,f',