Skip to content

Commit e21d66e

Browse files
committed
Quote value starting with comment marker in minimal quote mode (apache#610).
Extract to local variable.
1 parent 525dca2 commit e21d66e

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

src/changes/changes.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
<action type="fix" dev="ggregory" due-to="OldTruckDriver, Gary Gregory" issue="CSV-326">Escape Reader values with quote and escape (#606).</action>
5757
<action type="fix" dev="ggregory" due-to="Dexter.k, Gary Gregory">Clear escape delimiter buffer before peek in isEscapeDelimiter (#608).</action>
5858
<action type="fix" dev="ggregory" due-to="Dexter.k, Gary Gregory">Escape quote char in printWithEscapes when QuoteMode is NONE (#609).</action>
59+
<action type="fix" dev="ggregory" due-to="Dexter.k, Gary Gregory">Quote value starting with comment marker in minimal quote mode (#610)..</action>
5960
<!-- ADD -->
6061
<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>
6162
<action type="add" dev="ggregory" due-to="Ruiqi Dong, Gary Gregory" issue="CSV-325">Add CSVParser.Builder.setByteOffset(long) (#604).</action>

src/test/java/org/apache/commons/csv/CSVPrinterTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1842,11 +1842,12 @@ void testQuoteCommentMarkerFirstChar() throws IOException {
18421842
// The marker past the first character does not start a comment, so only the leading-marker value is quoted.
18431843
printer.printRecord("a;b", ";c");
18441844
}
1845+
final String string = sw.toString();
18451846
assertEquals("; a real comment" + RECORD_SEPARATOR +
18461847
"\";comment-like\",b" + RECORD_SEPARATOR +
1847-
"a;b,\";c\"" + RECORD_SEPARATOR, sw.toString());
1848+
"a;b,\";c\"" + RECORD_SEPARATOR, string);
18481849
// The comment is dropped on read; both data records survive intact.
1849-
try (CSVParser parser = CSVParser.parse(sw.toString(), format)) {
1850+
try (CSVParser parser = CSVParser.parse(string, format)) {
18501851
final List<CSVRecord> records = parser.getRecords();
18511852
assertEquals(2, records.size());
18521853
assertEquals(col1, records.get(0).get(0));

0 commit comments

Comments
 (0)