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

Should not quote with strict quoting when line starts with # but comments are disabled #270

Closed
kdebski85 opened this issue May 19, 2021 · 2 comments · Fixed by #271
Closed
Labels

Comments

@kdebski85
Copy link
Contributor

When STRICT_CHECK_FOR_QUOTING is enabled and withoutComments() is used, Jackson should not escape strings starting with "#"

CsvMapper mapper = new CsvMapper();
mapper.configure(CsvGenerator.Feature.ALWAYS_QUOTE_STRINGS, false);
mapper.configure(CsvGenerator.Feature.STRICT_CHECK_FOR_QUOTING, true);

CsvSchema schema = mapper.schemaFor(recordClass).withoutComments();
mapper.writerFor(recordClass).with(schema).writeValue(wrtiter, record);

The record contains a single string field with value #abc.

Expected:
#abc is written to CSV file

Actual:
"#abc" is written to CSV file

In CsvEncoder::_needsQuotingStrict "(c == '#' && i == 0)" should be checked only when comments are enabled.

kdebski85 pushed a commit to kdebski85/jackson-dataformats-text that referenced this issue May 19, 2021
…ments are disabled. Quote only the first column, fix FasterXML#270
@kdebski85
Copy link
Contributor Author

Additionally, in strict mode '#' should only add quotes if it is used in the first column. When it used in any other column, quotes are not needed.
I created pull request to address that. I will send CLA today.

@yawkat
Copy link
Member

yawkat commented May 20, 2021

fyi, tatu is away until next week, so you may have to wait a few days.

kdebski85 pushed a commit to kdebski85/jackson-dataformats-text that referenced this issue May 28, 2021
…ments are disabled. Quote only the first column, fix FasterXML#270
cowtowncoder pushed a commit that referenced this issue May 28, 2021
…ments are disabled. Quote only the first column, fix #270 (#271)

Co-authored-by: Krzysztof Debski <Krzysztof.Debski@IGT.com>
@cowtowncoder cowtowncoder changed the title [jackson-dataformat-csv] Should not quote with strict quoting when line starts with #, but comments are disabled Should not quote with strict quoting when line starts with # but comments are disabled May 28, 2021
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.

3 participants