Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#727 fix stale indexes used in whitespace tests during quote parsing. #728

Merged
merged 1 commit into from
Oct 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions papaparse.js
Original file line number Diff line number Diff line change
Expand Up @@ -1536,6 +1536,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);
Expand Down
16 changes: 16 additions & 0 deletions tests/test-cases.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: []
}
}
];

Expand Down