kessler / license-report

create a short report about a project's dependencies (license, url etc)
MIT License
236 stars 39 forks source link

Sanitize field values for csv format #31

Closed kessler closed 3 years ago

kessler commented 4 years ago

currently when outputting to csv some values might break csv because they have the delimiter character in them

BePo65 commented 4 years ago

do you have an example? I tried it with the project itself (node ./index.js --output=csv) and the output was fine.

But anyway: in case of problems you can change the delimiter anytime using the method described in the readme (see different output).

kessler commented 4 years ago

The most common delimiter which is , appeared for me once in the author field, as a result there was an extra column in that row. In my opinion it's always good to insure that protocols and formats are enforced... prevents a lot of nasty surprises

BePo65 commented 4 years ago

Hm, that's right for sure, but csv is not a standardized format We could surround all field values with quotes (or at least all values containing the separator) but then we would have to think about values containing quotes :-). And I am not sure, if all tools that import csv will accept quoted strings.

An alternative would be changing the field value by replacing all delimiter characters by another character - but what to use here?

What application do you have in mind that will import the generated csv file?

kessler commented 4 years ago

All very valid points!

We can start by throwing an error or just printing a warning that a delimiter character appears in a value and then maybe provide flags to do something with it (like escaping etc...)

wdyt?

BePo65 commented 4 years ago

good idea. Should I make a first draft of a solution as a pullrequest? Perhaps I find the time on the weekend?

kessler commented 4 years ago

That would be awesome.

On Wed, Oct 14, 2020, 07:31 BePo65 notifications@github.com wrote:

good idea. Should I make a first draft of a solution as a pullrequest? Perhaps I find the time on the weekend?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ironSource/license-report/issues/31#issuecomment-708149595, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABD7J4R7656Q6L3COOGIWTSKUSRVANCNFSM4SKMAFKQ .