jackson-dataformats-text
jackson-dataformats-text copied to clipboard
CSV STRICT_CHECK_FOR_QUOTING does not enclose value with newline character in double quotes
If I enable STRICT_CHECK_FOR_QUOTING
public static void main(String[] args) throws JsonProcessingException {
CsvFactory csvFactory = new CsvFactory();
csvFactory.enable(CsvGenerator.Feature.STRICT_CHECK_FOR_QUOTING);
ObjectMapper objectMapper = Jackson.newObjectMapper(csvFactory);
ObjectWriter writer = objectMapper.writer();
String s = writer.writeValueAsString("line1\nline2");
System.out.println(s);
}
The output is:
line1
line2
But when I disable the Feature, output becomes
"line1
line2"
If I change the newline character to a comma, the value is enclosed no matter I enable or disable this Feature:
"line1,line2"
This does not follow the https://www.ietf.org/rfc/rfc4180.txt item 2.6
That does seem wrong to me, thank you for reporting.
Quick question: which version did you test with?
We are on jackson-dataformat-csv-2.9.10.jar
@zhuhw That is a rather old version (almost 5 years ago) and a lot has changed since then. Does the problem still occur with, say, 2.17.1?
I can try it now, but for future reference it is very strongly recommended to test with the latest release version to avoid wasting everyone's time on bugs that have already been fixed (or behavior changed).
For example, #220 was fixed for 2.11.3 and seems like that might be fix for your issue @zhuhw ?
Assuming this was fixed since I have seen no updates; closing.
May be re-opened with reproduction against recent version, if this still occurs.