Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 3887C200BA8 for ; Mon, 24 Oct 2016 15:19:00 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 35C92160AEB; Mon, 24 Oct 2016 13:19:00 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 79F18160AE1 for ; Mon, 24 Oct 2016 15:18:59 +0200 (CEST) Received: (qmail 42840 invoked by uid 500); 24 Oct 2016 13:18:58 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 42825 invoked by uid 99); 24 Oct 2016 13:18:58 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Oct 2016 13:18:58 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 6554D2C001E for ; Mon, 24 Oct 2016 13:18:58 +0000 (UTC) Date: Mon, 24 Oct 2016 13:18:58 +0000 (UTC) From: "Vladimir Eatwell (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CSV-200) CSVFormat cannot read its own output if input contain escape character followed by quote character MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Mon, 24 Oct 2016 13:19:00 -0000 [ 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 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 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)