This repository was archived by the owner on Jan 22, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
main/java/com/fasterxml/jackson/dataformat/csv/impl
test/java/com/fasterxml/jackson/dataformat/csv Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -563,10 +563,17 @@ public String nextString() throws IOException
563563 _textBuffer .resetWithString ("" );
564564 return "" ;
565565 }
566+
566567 char [] outBuf = _textBuffer .emptyAndGetCurrentSegment ();
567568 outBuf [0 ] = (char ) i ;
568569 int outPtr = 1 ;
569570
571+ if (i == _escapeChar ) {
572+ // Reset the escaped character
573+ outBuf [0 ] = _unescape ();
574+ return _nextUnquotedString (outBuf , outPtr );
575+ }
576+
570577 int ptr = _inputPtr ;
571578 if (ptr >= _inputEnd ) {
572579 if (!loadMore ()) { // ok to have end-of-input but...
Original file line number Diff line number Diff line change @@ -47,5 +47,16 @@ public void testSimpleEscapesInUnquoted() throws Exception
4747 assertEquals ("abc\\ def" , result .id );
4848 assertEquals ("Desc with\n linefeed" , result .desc );
4949 }
50-
50+
51+ public void testEscapesAtStartInUnquoted () throws Exception
52+ {
53+ CsvMapper mapper = mapperForCsv ();
54+ CsvSchema schema = mapper .schemaFor (Desc .class ).withColumnSeparator ('|' ).withEscapeChar ('\\' );
55+ final String id = "\\ |abcdef" ; // doubled for javac
56+ final String desc = "Desc with\\ \n linefeed" ;
57+ String input = id +"|" +desc +"\n " ;
58+ Desc result = mapper .reader (schema ).withType (Desc .class ).readValue (input );
59+ assertEquals ("|abcdef" , result .id );
60+ assertEquals ("Desc with\n linefeed" , result .desc );
61+ }
5162}
You can’t perform that action at this time.
0 commit comments