Quote value starting with comment marker in minimal quote mode (#610). Extract to local variable.
diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 41b1a03..431da6b 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml
@@ -56,6 +56,7 @@ <action type="fix" dev="ggregory" due-to="OldTruckDriver, Gary Gregory" issue="CSV-326">Escape Reader values with quote and escape (#606).</action> <action type="fix" dev="ggregory" due-to="Dexter.k, Gary Gregory">Clear escape delimiter buffer before peek in isEscapeDelimiter (#608).</action> <action type="fix" dev="ggregory" due-to="Dexter.k, Gary Gregory">Escape quote char in printWithEscapes when QuoteMode is NONE (#609).</action> + <action type="fix" dev="ggregory" due-to="Dexter.k, Gary Gregory">Quote value starting with comment marker in minimal quote mode (#610)..</action> <!-- ADD --> <action type="add" dev="ggregory" due-to="Gary Gregory, Indy, Sylvia van Os" issue="CSV-307">Add an "Android Compatibility" section to the web site.</action> <action type="add" dev="ggregory" due-to="Ruiqi Dong, Gary Gregory" issue="CSV-325">Add CSVParser.Builder.setByteOffset(long) (#604).</action>
diff --git a/src/test/java/org/apache/commons/csv/CSVPrinterTest.java b/src/test/java/org/apache/commons/csv/CSVPrinterTest.java index f4f3c85..e68d4c2 100644 --- a/src/test/java/org/apache/commons/csv/CSVPrinterTest.java +++ b/src/test/java/org/apache/commons/csv/CSVPrinterTest.java
@@ -1842,11 +1842,12 @@ // The marker past the first character does not start a comment, so only the leading-marker value is quoted. printer.printRecord("a;b", ";c"); } + final String string = sw.toString(); assertEquals("; a real comment" + RECORD_SEPARATOR + "\";comment-like\",b" + RECORD_SEPARATOR + - "a;b,\";c\"" + RECORD_SEPARATOR, sw.toString()); + "a;b,\";c\"" + RECORD_SEPARATOR, string); // The comment is dropped on read; both data records survive intact. - try (CSVParser parser = CSVParser.parse(sw.toString(), format)) { + try (CSVParser parser = CSVParser.parse(string, format)) { final List<CSVRecord> records = parser.getRecords(); assertEquals(2, records.size()); assertEquals(col1, records.get(0).get(0));