Skip to content

Commit d5420fa

Browse files
Henning Schmiedehausenpjankovsky
Henning Schmiedehausen
authored andcommitted
Make sure that loose quote check also looks at the escape characters.
1 parent a9ce6fa commit d5420fa

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

csv/src/main/java/com/fasterxml/jackson/dataformat/csv/impl/CsvEncoder.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package com.fasterxml.jackson.dataformat.csv.impl;
22

3-
import java.io.IOException;
4-
import java.io.Writer;
5-
import java.util.Arrays;
6-
73
import com.fasterxml.jackson.core.io.CharTypes;
84
import com.fasterxml.jackson.core.io.IOContext;
95
import com.fasterxml.jackson.dataformat.csv.CsvGenerator;
106
import com.fasterxml.jackson.dataformat.csv.CsvGenerator.Feature;
117
import com.fasterxml.jackson.dataformat.csv.CsvSchema;
128

9+
import java.io.IOException;
10+
import java.io.Writer;
11+
import java.util.Arrays;
12+
1313
/**
1414
* Helper class that handles actual low-level construction of
1515
* CSV output, based only on indexes given without worrying about reordering,
@@ -1039,8 +1039,14 @@ protected boolean _mayNeedQuotes(String value, int length)
10391039
*/
10401040
protected final boolean _needsQuotingLoose(String value)
10411041
{
1042+
char esc1 = _cfgQuoteCharEscapeChar;
1043+
char esc2 = _cfgControlCharEscapeChar;
1044+
10421045
for (int i = 0, len = value.length(); i < len; ++i) {
1043-
if (value.charAt(i) < _cfgMinSafeChar) {
1046+
char c = value.charAt(i);
1047+
if ((c < _cfgMinSafeChar)
1048+
|| (c == esc1)
1049+
|| (c == esc2)) {
10441050
return true;
10451051
}
10461052
}

0 commit comments

Comments
 (0)