mafintosh / mafintosh/csv-parser

Double quotes in double-quoted values not handled correctly

Open
#70 10 comments 12 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

c³ ⋅ PR welcome t¹ 🐞 bug
Dominant language
JavaScript
Stars
1.5k
Forks
143
PR merge metrics
No merged PRs in 30d

Description

Double quotes inside double-quoted values cause the parser to stop parsing at the row containing the double quote. When I run this:

`printf 'name,age\njoe,40\n"will"iam",30\n"sam",35\n"jan",25' | csv-parser`
`-------------------------------^ there's a double quote in here`

I get this:

```
{"name":"joe","age":"40"}
{"name":"will\"iam","age":"30\n\"sam\""}
```

It escaped the double quote nicely, but the "age" field is wrong, and the third and fourth rows were never parsed at all.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with the provided printf input piped to csv-parser, then trace how the parser handles double-quoted fields containing an internal quote. Done means the sample produces four rows, with the will"iam name preserved and the age values assigned to the correct rows.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.