From d5e2fae859126ef50343148b06bdee694141be63 Mon Sep 17 00:00:00 2001 From: David Boskovic Date: Mon, 29 Jul 2019 01:37:08 -0600 Subject: [PATCH] Resolve parsing issue when first field is empty and unquoted (#696) --- papaparse.js | 2 +- tests/test-cases.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/papaparse.js b/papaparse.js index acf4c95..b64d201 100755 --- a/papaparse.js +++ b/papaparse.js @@ -1608,7 +1608,7 @@ License: MIT var nextDelimObj = getNextUnqotedDelimiter(nextDelim, quoteSearch, nextNewline); // if we have next delimiter char which is not enclosed in quotes - if (nextDelimObj && nextDelimObj.nextDelim) { + if (nextDelimObj && typeof nextDelimObj.nextDelim !== 'undefined') { nextDelim = nextDelimObj.nextDelim; quoteSearch = nextDelimObj.quoteSearch; row.push(input.substring(cursor, nextDelim)); diff --git a/tests/test-cases.js b/tests/test-cases.js index 81a2dce..45db0e6 100644 --- a/tests/test-cases.js +++ b/tests/test-cases.js @@ -323,6 +323,14 @@ var CORE_PARSER_TESTS = [ errors: [] } }, + { + description: "Line starts with unquoted empty field", + input: ',b,c\n"d",e,f', + expected: { + data: [['', 'b', 'c'], ['d', 'e', 'f']], + errors: [] + } + }, { description: "Line ends with quoted field", input: 'a,b,c\nd,e,f\n"g","h","i"\n"j","k","l"',