Repository: mholt/PapaParse (js)

Issue:
Incorrect result when last record ends with an empty quoted value
Consider this example:
```csv
a,1,""
b,2,""
c,3,""
```
Parsing this structure results in the following data:
```json
[
    [
        "a",
        "1",
        ""
    ],
    [
        "b",
        "2",
        ""
    ],
    [
        "c",
        "3",
        "\""
    ]
]
```
Notice that the last string value contains an extra double quote, which is incorrect IMHO. I'd at least expect every record to be treated equally.

Pull request description:
handle empty quoted field at EOF
fixes #238 

Patch:
diff --git a/papaparse.js b/papaparse.js
index 958d0ac..c3c1f48 100644
--- a/papaparse.js
+++ b/papaparse.js
@@ -1201,7 +1201,7 @@
 			{
 				if (ignoreLastRow)
 					return returnable();
-				if (!value)
+				if (typeof value === 'undefined')
 					value = input.substr(cursor);
 				row.push(value);
 				cursor = inputLen;	// important in case parsing is paused


Test patch:
diff --git a/tests/test-cases.js b/tests/test-cases.js
index 48ee0c8..cbd7a1c 100644
--- a/tests/test-cases.js
+++ b/tests/test-cases.js
@@ -219,6 +219,14 @@ var CORE_PARSER_TESTS = [
 			errors: []
 		}
 	},
+  {
+    description: "Empty quoted field at EOF is empty",
+    input: 'a,b,""\na,b,""',
+    expected: {
+      data: [['a', 'b', ''], ['a', 'b', '']],
+      errors: []
+    }
+  },
 	{
 		description: "Multiple consecutive empty fields",
 		input: 'a,b,,,c,d\n,,e,,,f',