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 @@
/* /*
Papa Parse Papa Parse
v3.0.0 v3.0.1
https://github.com/mholt/PapaParse https://github.com/mholt/PapaParse
*/ */
(function(global) (function(global)
@ -1063,7 +1063,7 @@
function quotesOnBoundary() function quotesOnBoundary()
{ {
return isBoundary(_i-1) || isBoundary(_i+1); return (!_inQuotes && isBoundary(_i-1)) || isBoundary(_i+1);
} }
function isBoundary(i) function isBoundary(i)
@ -1073,12 +1073,10 @@
var ch = _input[i]; var ch = _input[i];
return (i == -1 || i == _input.length) return (i <= -1 || i >= _input.length)
|| (i < _input.length || (ch == _delimiter
&& i > -1
&& (ch == _delimiter
|| ch == "\r" || ch == "\r"
|| ch == "\n")); || ch == "\n");
} }
function addError(type, code, msg) 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 @@
{ {
"name": "parse", "name": "parse",
"version": "3.0.0", "version": "3.0.1",
"title": "Papa Parse", "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.", "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": [ "keywords": [
@ -27,7 +27,7 @@
"author": { "author": {
"name": "Matthew Holt", "name": "Matthew Holt",
"email": "mholt@users.noreply.github.com", "email": "mholt@users.noreply.github.com",
"url": "http://mwholt.com" "url": "https://twitter.com/mholt6"
}, },
"licenses": [ "licenses": [
{ {

18
tests/test-cases.js

@ -112,6 +112,24 @@ var TESTS = [
errors: [] 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', input: 'A, "B" ,C',
description: "Quoted field with whitespace around quotes", description: "Quoted field with whitespace around quotes",

Loading…
Cancel
Save