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

Invalid parsing when quote is escaped inside quoted column containing delimiter #318

Closed
mayorandrew opened this issue Apr 24, 2019 · 1 comment
Milestone

Comments

@mayorandrew
Copy link

mayorandrew commented Apr 24, 2019

I have noticed that the following csv is parsed incorrectly:

"c1"|"c2"|"c3"
"1"|"{2\"|3}"|"4"

The following code:

csv({delimiter:'|', escape: '\\', quote: '"'})
.fromString(`"c1"|"c2"|"c3"\n"1"|"{2\\"|3}"|"4"`)
.then((d) => console.log(d))

results in printing:

[ { c1: '1', c2: '"{2\\"', c3: '3}"', field4: '4' } ]

while the expected result is:

[ { c1: '1', c2: '{2"|3}', c3: '4' } ]

I noticed that it only happens when both escaped quote and delimiter are contained inside quoted column, i.e. the following csvs are parsed correctly:

"c1"|"c2"|"c3"
"1"|"{2|3}"|"4"

=>

[ { c1: '1', c2: '{2|3}', c3: '4' } ]
"c1"|"c2"|"c3"
"1"|"{2\"3}"|"4"

=>

[ { c1: '1', c2: '{2"3}', c3: '4' } ]
risseraka added a commit to risseraka/node-csvtojson that referenced this issue Jun 9, 2019
risseraka added a commit to risseraka/node-csvtojson that referenced this issue Jun 9, 2019
risseraka added a commit to risseraka/node-csvtojson that referenced this issue Jun 9, 2019
@Keyang Keyang added this to the 2.0.9 milestone Jun 20, 2019
@Keyang
Copy link
Owner

Keyang commented Jun 26, 2019

will be shipped with 2.0.9

@Keyang Keyang closed this as completed Jun 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants