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

CSV writer doesn't escape / remove commas & newlines #223

Closed
agonzalez-plume opened this issue Aug 10, 2022 · 0 comments · Fixed by #245
Closed

CSV writer doesn't escape / remove commas & newlines #223

agonzalez-plume opened this issue Aug 10, 2022 · 0 comments · Fixed by #245
Labels

Comments

@agonzalez-plume
Copy link

The csv output formatter gets confused when commas exist in the text being outputted. The commas could simply be removed is probably the easiest.

As well newline characters seem to confused it too for instance '\n' in the description causes problems.

fixing could be as simple as doing:
csvreport.kt:82:

element.replace(",", " ").replace("\n"," ")

I haven't done a plugin change before, so not entirely sure how to test out the change locally before committing.

I have good results with the json output, so I'm using dasel to convert json to csv and it's close to what I want, but the csvwriter output would be better.

I see a similar problem with HTML output being mixed up, but I think some others were seeing similar issues.

danielesegato added a commit to danielesegato/gradle-license-plugin that referenced this issue Mar 1, 2023
the default escape character for CSV is " which has to be escaped with a
double ""

Additionally, when a column contains any of these character it has to be put inside
quotes:

- " (double quote)
- , (comma)
- ' (single quote)
- \ (backslash)
- \n (new line)
jaredsburrows pushed a commit that referenced this issue Mar 1, 2023
the default escape character for CSV is " which has to be escaped with a
double ""

Additionally, when a column contains any of these character it has to be put inside
quotes:

- " (double quote)
- , (comma)
- ' (single quote)
- \ (backslash)
- \n (new line)

Co-authored-by: Daniele Segato <daniele.segato@neosperience.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants