Skip to content

Commit bdb5842

Browse files
committed
Validation fails if no quotes mode set but no escape character is set.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1398148 13f79535-47bb-0310-9956-ffa450edef68
1 parent f51f43d commit bdb5842

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

src/main/java/org/apache/commons/csv/CSVFormat.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,10 @@ void validate() throws IllegalStateException {
199199
if (escape != null && escape == commentStart) {
200200
throw new IllegalStateException("The comment start and the escape character cannot be the same ('" + commentStart + "')");
201201
}
202+
203+
if (escape == null && quotePolicy == Quote.NONE) {
204+
throw new IllegalStateException("No quotes mode set but no escape character is set");
205+
}
202206
}
203207

204208
/**

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,14 @@ public void testValidation() {
153153
} catch (final IllegalStateException e) {
154154
// expected
155155
}
156-
}
156+
157+
try {
158+
format.withQuoteChar('!').withQuotePolicy(Quote.NONE).validate();
159+
fail();
160+
} catch (final IllegalStateException e) {
161+
// expected
162+
}
163+
}
157164

158165
@SuppressWarnings("boxing") // no need to worry about boxing here
159166
@Test

0 commit comments

Comments
 (0)