diff --git a/src/main/java/com/j256/simplecsv/processor/CsvProcessor.java b/src/main/java/com/j256/simplecsv/processor/CsvProcessor.java index e7b3af5..2fd11c2 100644 --- a/src/main/java/com/j256/simplecsv/processor/CsvProcessor.java +++ b/src/main/java/com/j256/simplecsv/processor/CsvProcessor.java @@ -1278,7 +1278,7 @@ private void processQuotedColumn(LineInfo lineInfo, BufferedReader bufferedReade int sectionEnd = linePos; StringBuilder sb = null; - while (linePos < line.length()) { + while (true) { // look for the next quote sectionEnd = line.indexOf(columnQuote, linePos); @@ -1294,7 +1294,7 @@ private void processQuotedColumn(LineInfo lineInfo, BufferedReader bufferedReade } // add the end of the line sb.append(line, sectionStart, line.length()); - // is this right if the line termination of the file doesn't match the system? + // add the line-termination in the middle of this column which will _hopefully_ match the file sb.append(lineTermination); // restart from the next line read line = nextLine; diff --git a/src/main/javadoc/doc-files/changelog.txt b/src/main/javadoc/doc-files/changelog.txt index a936503..49c1b44 100644 --- a/src/main/javadoc/doc-files/changelog.txt +++ b/src/main/javadoc/doc-files/changelog.txt @@ -1,3 +1,6 @@ +2.5: 2/15/2019 + * Fixed an immediate bug that I found when line-termination character an a blank line are inside a column. + 2.4: 2/15/2019 * Added handling of line-termination characters inside of columns if enabled. * Added a setting to load the fields from any super-classes _before_ the subclasses. diff --git a/src/test/java/com/j256/simplecsv/processor/CsvProcessorTest.java b/src/test/java/com/j256/simplecsv/processor/CsvProcessorTest.java index 21b4dea..d2ac1eb 100644 --- a/src/test/java/com/j256/simplecsv/processor/CsvProcessorTest.java +++ b/src/test/java/com/j256/simplecsv/processor/CsvProcessorTest.java @@ -850,6 +850,11 @@ public void testNewlineInColumn() throws Exception { str = "short\n" + "loooooooooooong\n" + "short"; basic = new Basic(0, str, 0, "foo", false); testReadWriteBasic(processor, basic); + + // blank line in the middle + str = "short\n\n" + "loooooooooooong\n" + "short"; + basic = new Basic(0, str, 0, "foo", false); + testReadWriteBasic(processor, basic); } @Test(expected = ParseException.class)