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

[BUG] CsvFormatterStream fails to "quote" fields with \r #320

Closed
trujaytim opened this issue Feb 5, 2020 · 2 comments
Closed

[BUG] CsvFormatterStream fails to "quote" fields with \r #320

trujaytim opened this issue Feb 5, 2020 · 2 comments
Assignees
Labels

Comments

@trujaytim
Copy link

Describe the bug
If one of the properties (fields) in the object passed to the write(...) function contains a carriage return (with no following line feed), the resulting output csv is malformed as the field is not quoted. Typical csv parsers, including fast-csv, will treat the this source row as 2 csv lines.

To Reproduce
Send the object below to the write(...) function:
{a: "Line 1\rLine 2"}
The resulting csv file will be as follows (note: I have added the [CR] and [LF] markers for readabilityin the example below):

a[LF]
Line 1[CR]
Line 2

I would expect this instead:

a[LF]
"Line 1[CR]
Line 2"

Interestingly, if the [CR] is followed by an [LF] the output is correct.

Desktop (please complete the following information):

  • OS: Windows 10; Ubuntu 18
  • Node Version [e.g. 12.8.0]
@trujaytim trujaytim added the bug label Feb 5, 2020
doug-martin added a commit that referenced this issue Feb 14, 2020
* [FIXED] Issue where carriage returns and line feeds were not always quoted when formatting #320
doug-martin added a commit that referenced this issue Feb 14, 2020
@doug-martin
Copy link
Contributor

Thanks for submitting this issue!

This will be published in v4.0.3

@doug-martin doug-martin mentioned this issue Feb 14, 2020
@doug-martin
Copy link
Contributor

published!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants