Browse Source

Fix misplaced quotes parsing (#702)

Closes #699
pull/704/head
Seito Tanaka 5 years ago committed by Sergi Almacellas Abellana
parent
commit
874161a23d
  1. 2
      papaparse.js
  2. 8
      tests/test-cases.js

2
papaparse.js

@ -1603,7 +1603,7 @@ License: MIT @@ -1603,7 +1603,7 @@ License: MIT
if (nextDelim !== -1 && (nextDelim < nextNewline || nextNewline === -1))
{
// we check, if we have quotes, because delimiter char may be part of field enclosed in quotes
if (quoteSearch !== -1) {
if (quoteSearch > nextDelim) {
// we have quotes, so we try to find the next delimiter not enclosed in quotes and also next starting quote char
var nextDelimObj = getNextUnqotedDelimiter(nextDelim, quoteSearch, nextNewline);

8
tests/test-cases.js

@ -670,6 +670,14 @@ var PARSE_TESTS = [ @@ -670,6 +670,14 @@ var PARSE_TESTS = [
errors: []
}
},
{
description: "Misplaced quotes in data twice, not as opening quotes",
input: 'A,B",C\nD,E",F',
expected: {
data: [['A', 'B"', 'C'], ['D', 'E"', 'F']],
errors: []
}
},
{
description: "Mixed slash n and slash r should choose first as precident",
input: 'a,b,c\nd,e,f\rg,h,i\n',

Loading…
Cancel
Save