Skip to content

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

Closed
@kdebski85

Description

@kdebski85

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions