csv-stringify doesn't automatically quote strings with \r line endings
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 4.3k
- Forks
- 299
- Avg merge
- 16h 19m
- Merged PRs (30d)
- 1
Description
Describe the bug
The csv-stringify package doesn't treat \r symbol as a line ending. So it doesnt automatically quotes strings with this line ending. It may lead to unexpected behavior when other apps read generated csv's.
I use csv-stringify 5.5.0
To Reproduce
This is an example to reproduce the issue. I haven't tested it but it should work
const stringify = require('csv-stringify/lib/sync')
const columns = [{ key: 'testColumn' }]
const records = [{ testColumn: 'test \r test' }]
const data = stringify(records, {
eof: false,
header: true,
delimiter: '\t',
recordDelimeter: 'unix',
columns,
// uncomment next line for a workaround
// quotedMatch: '\r'
})
console.log(data)
Produced tsv will have a record with an unqouted value with line endings
Additional context
- This
\rline ending is not common but it exists. It is supported by code editors and apps - There's a workaround in the example above
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at csv-stringify/lib/sync and reproduce the example from the issue with a field containing a \r character. Confirm the generated TSV quotes that field automatically, without requiring the quotedMatch workaround, and verify the existing behavior for other line endings remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- data
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100