Browse Source

#727 update delimiter and newline index if they are earlier than the current position before tested. (#728)

pull/729/head
jseter 5 years ago committed by Sergi Almacellas Abellana
parent
commit
47b356d6e0
  1. 6
      papaparse.js
  2. 16
      tests/test-cases.js

6
papaparse.js

@ -1539,6 +1539,12 @@ License: MIT @@ -1539,6 +1539,12 @@ License: MIT
continue;
}
if(nextDelim !== -1 && nextDelim < (quoteSearch + 1)) {
nextDelim = input.indexOf(delim, (quoteSearch + 1));
}
if(nextNewline !== -1 && nextNewline < (quoteSearch + 1)) {
nextNewline = input.indexOf(newline, (quoteSearch + 1));
}
// Check up to nextDelim or nextNewline, whichever is closest
var checkUpTo = nextNewline === -1 ? nextDelim : Math.min(nextDelim, nextNewline);
var spacesBetweenQuoteAndDelimiter = extraSpaces(checkUpTo);

16
tests/test-cases.js

@ -1464,6 +1464,22 @@ var PARSE_TESTS = [ @@ -1464,6 +1464,22 @@ var PARSE_TESTS = [
data: [['a', 'b'], ['c', 'd'], [' , ', ','], ['" "', '""']],
errors: []
}
},
{
description: "Quoted fields with spaces between closing quote and next delimiter and contains delimiter",
input: 'A,",B" ,C,D\nE,F,G,H',
expected: {
data: [['A', ',B', 'C', 'D'],['E', 'F', 'G', 'H']],
errors: []
}
},
{
description: "Quoted fields with spaces between closing quote and newline and contains newline",
input: 'a,b,"c\n" \nd,e,f',
expected: {
data: [['a', 'b', 'c\n'], ['d', 'e', 'f']],
errors: []
}
}
];

Loading…
Cancel
Save