Browse Source

Fix for special case of quotes around delimiter in quoted field (fixes #67)

pull/70/head 3.0.1
Matthew Holt 11 years ago
parent
commit
e29134423e
  1. 12
      papaparse.js
  2. 4
      papaparse.min.js
  3. 4
      parse.jquery.json
  4. 18
      tests/test-cases.js

12
papaparse.js

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
/*
Papa Parse
v3.0.0
v3.0.1
https://github.com/mholt/PapaParse
*/
(function(global)
@ -1063,7 +1063,7 @@ @@ -1063,7 +1063,7 @@
function quotesOnBoundary()
{
return isBoundary(_i-1) || isBoundary(_i+1);
return (!_inQuotes && isBoundary(_i-1)) || isBoundary(_i+1);
}
function isBoundary(i)
@ -1073,12 +1073,10 @@ @@ -1073,12 +1073,10 @@
var ch = _input[i];
return (i == -1 || i == _input.length)
|| (i < _input.length
&& i > -1
&& (ch == _delimiter
return (i <= -1 || i >= _input.length)
|| (ch == _delimiter
|| ch == "\r"
|| ch == "\n"));
|| ch == "\n");
}
function addError(type, code, msg)

4
papaparse.min.js vendored

File diff suppressed because one or more lines are too long

4
parse.jquery.json

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
{
"name": "parse",
"version": "3.0.0",
"version": "3.0.1",
"title": "Papa Parse",
"description": "Powerful CSV parser that converts CSV to JSON and JSON to CSV. Supports web workers and streaming large files. Gracefully handles malformed input.",
"keywords": [
@ -27,7 +27,7 @@ @@ -27,7 +27,7 @@
"author": {
"name": "Matthew Holt",
"email": "mholt@users.noreply.github.com",
"url": "http://mwholt.com"
"url": "https://twitter.com/mholt6"
},
"licenses": [
{

18
tests/test-cases.js

@ -112,6 +112,24 @@ var TESTS = [ @@ -112,6 +112,24 @@ var TESTS = [
errors: []
}
},
{
input: 'A,""",""",C',
description: "Quoted field with quotes around delimiter",
notes: "For a boundary to exist immediately before the quotes, we must not already be in quotes",
expected: {
data: [['A', '","', 'C']],
errors: []
}
},
{
input: 'A,",""",C',
description: "Quoted field with quotes on one side of delimiter",
notes: "Similar to the test above but with quotes only after the delimiter",
expected: {
data: [['A', ',"', 'C']],
errors: []
}
},
{
input: 'A, "B" ,C',
description: "Quoted field with whitespace around quotes",

Loading…
Cancel
Save