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: Should quote strings with line separator under STRICT_CHECK_FOR_QUOTING mode #217

Closed
wkwkhautbois opened this issue Aug 21, 2020 · 1 comment
Labels
Milestone

Comments

@wkwkhautbois
Copy link

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

wkwkhautbois added a commit to wkwkhautbois/jackson-dataformats-text that referenced this issue Aug 29, 2020
wkwkhautbois added a commit to wkwkhautbois/jackson-dataformats-text that referenced this issue Aug 29, 2020
@cowtowncoder cowtowncoder changed the title CSV: NOT quote strings with line separator under STRICT_CHECK_FOR_QUOTING mode. CSV: should quote strings with line separator under STRICT_CHECK_FOR_QUOTING mode Aug 29, 2020
@cowtowncoder cowtowncoder added this to the 2.11.3 milestone Sep 24, 2020
@cowtowncoder cowtowncoder changed the title CSV: should quote strings with line separator under STRICT_CHECK_FOR_QUOTING mode CSV: Should quote strings with line separator under STRICT_CHECK_FOR_QUOTING mode Sep 24, 2020
@cowtowncoder
Copy link
Member

@wkwkhautbois thank you once again for reporting this issue, contributing the fix. Will be in 2.11.3 / 2.12.0.

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

No branches or pull requests

2 participants