CSVFormat does not support explicit " as escape char

This commit is contained in:
Gary Gregory 2024-09-14 12:30:15 -04:00
parent afbeaed866
commit 28acf1138b
3 changed files with 7 additions and 14 deletions

View File

@ -50,6 +50,7 @@
<action type="fix" dev="ggregory" due-to="Dávid Szigecsán">Migrate CSVFormat#print(File, Charset) to NIO #445.</action> <action type="fix" dev="ggregory" due-to="Dávid Szigecsán">Migrate CSVFormat#print(File, Charset) to NIO #445.</action>
<action type="fix" dev="ggregory" due-to="Dávid Szigecsán">Fix documentation for CSVFormat private constructor #466.</action> <action type="fix" dev="ggregory" due-to="Dávid Szigecsán">Fix documentation for CSVFormat private constructor #466.</action>
<action type="fix" issue="CSV-294" dev="ggregory" due-to="Joern Huxhorn, Gary Gregory">CSVFormat does not support explicit " as escape char.</action> <action type="fix" issue="CSV-294" dev="ggregory" due-to="Joern Huxhorn, Gary Gregory">CSVFormat does not support explicit " as escape char.</action>
<action type="fix" issue="CSV-150" dev="ggregory" due-to="dota17, Gary Gregory, Jörn Huxhorn">CSVFormat does not support explicit " as escape char.</action>
<!-- UPDATE --> <!-- UPDATE -->
<action type="update" dev="ggregory" due-to="Dependabot">Bump commons-codec:commons-codec from 1.16.1 to 1.17.1 #422, #449.</action> <action type="update" dev="ggregory" due-to="Dependabot">Bump commons-codec:commons-codec from 1.16.1 to 1.17.1 #422, #449.</action>
<action type="update" dev="ggregory" due-to="Gary Gregory">Bump org.apache.commons:commons-parent from 69 to 74 #435, #452, #465, #468.</action> <action type="update" dev="ggregory" due-to="Gary Gregory">Bump org.apache.commons:commons-parent from 69 to 74 #435, #452, #465, #468.</action>

View File

@ -32,19 +32,12 @@ final class Lexer implements Closeable {
private static final String CR_STRING = Character.toString(Constants.CR); private static final String CR_STRING = Character.toString(Constants.CR);
private static final String LF_STRING = Character.toString(Constants.LF); private static final String LF_STRING = Character.toString(Constants.LF);
/**
* Constant char to use for disabling comments, escapes, and encapsulation. The value -2 is used because it
* won't be confused with an EOF signal (-1), and because the Unicode value {@code FFFE} would be encoded as two
* chars (using surrogates) and thus there should never be a collision with a real text char.
*/
private static final char DISABLED = '\ufffe';
private final char[] delimiter; private final char[] delimiter;
private final char[] delimiterBuf; private final char[] delimiterBuf;
private final char[] escapeDelimiterBuf; private final char[] escapeDelimiterBuf;
private final char escape; private final int escape;
private final char quoteChar; private final int quoteChar;
private final char commentStart; private final int commentStart;
private final boolean ignoreSurroundingSpaces; private final boolean ignoreSurroundingSpaces;
private final boolean ignoreEmptyLines; private final boolean ignoreEmptyLines;
private final boolean lenientEof; private final boolean lenientEof;
@ -197,8 +190,8 @@ final class Lexer implements Closeable {
return ch == Constants.LF || ch == Constants.CR || ch == Constants.UNDEFINED; return ch == Constants.LF || ch == Constants.CR || ch == Constants.UNDEFINED;
} }
private char mapNullToDisabled(final Character c) { private int mapNullToDisabled(final Character c) {
return c == null ? DISABLED : c.charValue(); // N.B. Explicit (un)boxing is intentional return c == null ? -1 : c.charValue(); // Explicit unboxing is intentional
} }
/** /**
@ -512,4 +505,5 @@ final class Lexer implements Closeable {
buffer.setLength(length); buffer.setLength(length);
} }
} }
} }

View File

@ -23,10 +23,8 @@ import java.io.StringReader;
import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVParser; import org.apache.commons.csv.CSVParser;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@Disabled
public class JiraCsv150Test { public class JiraCsv150Test {
private void testDisable(final CSVFormat csvFormat, final StringReader stringReader) throws IOException { private void testDisable(final CSVFormat csvFormat, final StringReader stringReader) throws IOException {