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 escape character should be at least empty or configurable in export definitions #374

Open
slri opened this issue Nov 2, 2022 · 0 comments

Comments

@slri
Copy link
Contributor

slri commented Nov 2, 2022

Q A
Bug report? yes
Feature request? yes
BC Break report? no
RFC? no
Branch? master

As it is right now CsvProvider doesn't even allow you to configure the escape character to be anything other than the default \. This poses a problem when exporting JSON in CSV because it has the tendency to break the necessary CSV quote escapes due to JSON needing it's own escapes for quotes inside strings.

Example JSON:

{"prop":"value with \"escaped double quotes\""}

Expected result:

"{""prop"":""value with \""escaped double quotes\""""}"

Actual result:

"{""prop"":""value with \"escaped double quotes\"""}"

The actual result breaks CSV columns, making the CSV data pretty much garbage (notice the JSON escaped quotes missing the CSV escaping in the actual result).
Due to the way that fputcsv works, escaping the escape character (eg. \\) doesn't change anything. Allowing for escape to be an empty string removes this limitation altogether and some specific usecases could benefit from escape character for CSV being configurable in the profile itself.

Bugfix:
Use empty string as the escape character passed to Writer.

Feature:
Allow escape character to be configured per profile, defaulting to empty string if none is present.

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

No branches or pull requests

2 participants