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

Incorrect header detection in CSV parsing 5.4.1 #1007

Open
lucas-inc-query opened this issue Jun 29, 2023 · 2 comments
Open

Incorrect header detection in CSV parsing 5.4.1 #1007

lucas-inc-query opened this issue Jun 29, 2023 · 2 comments

Comments

@lucas-inc-query
Copy link

lucas-inc-query commented Jun 29, 2023

I have encountered an issue with version 5.4.1 when parsing CSV headers. It seems that headers are being incorrectly parsed and appended with "_x".

To reproduce the issue, go to https://www.papaparse.com/demo, check the "Header row" box and parse the following string:

"foo,dog","foo,cat"

Inspecting the results > meta > fields property shows us the following array:

fields: [ "foo,dog", 'foo_1,cat"' ]

The 2 error messages are:

message: "Trailing quote on quoted field is malformed"
message: "Quoted field unterminated"

It seems that commas within the headers leads to the parser believing there duplicate header fields? This problem does not occur if the header: true option is omitted from the config.

@faulpeltz
Copy link

faulpeltz commented Jul 5, 2023

Unfortunately this seems to be the case with all quoted duplicate headers:
"bla","duplicate","duplicate","foo"

Results in:
fields: [ "bla", "duplicate", "duplicate\"_1,\"foo"]

  • It works correctly when the quotes are removed
  • Reverting to 5.3.2 also works (but has has no duplicate header renaming)

Edit:
As a follow up, looking at the code, the header duplicate detection code completely ignores quoting (just doing a separator split)

@basememara
Copy link

Related to #998

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

3 participants