[
https://issues.apache.org/jira/browse/CSV-200?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15601952#comment-15601952
]
Vladimir Eatwell commented on CSV-200:
--------------------------------------
Here's another case where the delimiter is ignored due to an escape character
at the end of the first value:
{code}
@Test
public void parseFailure2() throws Exception {
CSVFormat formatter = CSVFormat.EXCEL;
formatter = formatter.withDelimiter(',');
formatter = formatter.withQuote('"');
formatter = formatter.withEscape('\\');
formatter = formatter.withNullString("NULL");
formatter = formatter.withIgnoreSurroundingSpaces(true);
formatter = formatter.withQuoteMode(QuoteMode.MINIMAL);
String formatted = formatter.format("bob\\", "token");
List<CSVRecord> parsed = formatter.parse(new
StringReader(formatted)).getRecords();
for (CSVRecord record : parsed) {
assertThat(record.size(), is(2));
}
}
{code}
> CSVFormat cannot read its own output if input contain escape character
> followed by quote character
> --------------------------------------------------------------------------------------------------
>
> Key: CSV-200
> URL: https://issues.apache.org/jira/browse/CSV-200
> Project: Commons CSV
> Issue Type: Bug
> Components: Parser
> Affects Versions: 1.4
> Reporter: Vladimir Eatwell
>
> I can format CSV using CSVFormat that is subsequently unparsable by
> CSVFormat, the test below illustrates the failure:
> {code}
> import org.apache.commons.csv.CSVFormat;
> import org.apache.commons.csv.CSVRecord;
> import org.apache.commons.csv.QuoteMode;
> import org.junit.Test;
> import java.io.StringReader;
> import java.util.List;
> public class CSVFormatTest {
> @Test
> public void parseFailure() throws Exception {
> CSVFormat formatter = CSVFormat.DEFAULT;
> formatter = formatter.withDelimiter(',');
> formatter = formatter.withQuote('*');
> formatter = formatter.withEscape('/');
> formatter = formatter.withNullString("NULL");
> formatter = formatter.withIgnoreSurroundingSpaces(true);
> formatter = formatter.withQuoteMode(QuoteMode.MINIMAL);
> String formatted = formatter.format("bob/*", "token");
> List<CSVRecord> parsed = formatter.parse(new
> StringReader(formatted)).getRecords();
> for (CSVRecord record : parsed) {
> System.out.println(record.size());
> }
> }
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)