Skip to content

CSV: Should quote strings with line separator under STRICT_CHECK_FOR_QUOTING mode #217

Description

@wkwkhautbois

When string data with line separator is serialized to csv, it shold be quoted, shouldn't it?
But it actually is NOT quoted if CsvGenerator.Feature.STRICT_CHECK_FOR_QUOTING is enabled.

Test below is failed:

public void testExplicitWithLineSeparator() throws Exception
{
    CsvSchema schema = CsvSchema.emptySchema();
    ObjectWriter writer =  new CsvMapper().writer(schema)
            .with(CsvGenerator.Feature.STRICT_CHECK_FOR_QUOTING);

    String csv =writer.writeValueAsString(new Object[]{"abc", "de\nf", "ghi"});
    assertEquals("abc,\"de\nf\",ghi\n", csv);  // FAILED!
}
expected:<abc,["de
f"],ghi
> but was:<abc,[de
f],ghi
>

version: v.2.11.2 and currrent master branch

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions