This repository was archived by the owner on Jan 22, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +30
-1
lines changed
main/java/com/fasterxml/jackson/dataformat/csv/impl
test/java/com/fasterxml/jackson/dataformat/csv/deser Expand file tree Collapse file tree 4 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -34,4 +34,11 @@ Luke Nezda (nezda@github)
3434* Suggested #56: Support comments (either via `CsvSchema`, or using std
3535 `JsonParser.Feature.ALLOW_YAML_COMMENTS.
3636 (requested by nezda@github)
37- (2.5.0)
37+ (2.5.0)
38+
39+ David Navas (davidnavas@github)
40+
41+ * Contributed #75: Support escapes at beginning of the file
42+ (2.5.3)
43+
44+
Original file line number Diff line number Diff line change @@ -4,6 +4,11 @@ Project: jackson-dataformat-csv
44=== Releases ===
55------------------------------------------------------------------------
66
7+ 2.5.3 (not yet released)
8+
9+ #75: Support escapes at beginning of the file
10+ (contributed by David N)
11+
7122.5.2 (29-Mar-2015)
813
914#66: Deserializing an empty string as an array field return a non-empty list of one empty String
Original file line number Diff line number Diff line change @@ -632,6 +632,12 @@ public String nextString() throws IOException
632632 outBuf [0 ] = (char ) i ;
633633 int outPtr = 1 ;
634634
635+ if (i == _escapeChar ) {
636+ // Reset the escaped character
637+ outBuf [0 ] = _unescape ();
638+ return _nextUnquotedString (outBuf , outPtr );
639+ }
640+
635641 int ptr = _inputPtr ;
636642 if (ptr >= _inputEnd ) {
637643 if (!loadMore ()) { // ok to have end-of-input but...
Original file line number Diff line number Diff line change @@ -51,4 +51,15 @@ public void testSimpleEscapesInUnquoted() throws Exception
5151 assertEquals ("Desc with\n linefeed" , result .desc );
5252 }
5353
54+ public void testEscapesAtStartInUnquoted () throws Exception
55+ {
56+ CsvMapper mapper = mapperForCsv ();
57+ CsvSchema schema = mapper .schemaFor (Desc .class ).withColumnSeparator ('|' ).withEscapeChar ('\\' );
58+ final String id = "\\ |abcdef" ; // doubled for javac
59+ final String desc = "Desc with\\ \n linefeed" ;
60+ String input = id +"|" +desc +"\n " ;
61+ Desc result = mapper .reader (schema ).withType (Desc .class ).readValue (input );
62+ assertEquals ("|abcdef" , result .id );
63+ assertEquals ("Desc with\n linefeed" , result .desc );
64+ }
5465}
You can’t perform that action at this time.
0 commit comments