This repository was archived by the owner on Jan 22, 2019. It is now read-only.
File tree 2 files changed +19
-1
lines changed
main/java/com/fasterxml/jackson/dataformat/csv/impl
test/java/com/fasterxml/jackson/dataformat/csv
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
563
563
_textBuffer .resetWithString ("" );
564
564
return "" ;
565
565
}
566
+
566
567
char [] outBuf = _textBuffer .emptyAndGetCurrentSegment ();
567
568
outBuf [0 ] = (char ) i ;
568
569
int outPtr = 1 ;
569
570
571
+ if (i == _escapeChar ) {
572
+ // Reset the escaped character
573
+ outBuf [0 ] = _unescape ();
574
+ return _nextUnquotedString (outBuf , outPtr );
575
+ }
576
+
570
577
int ptr = _inputPtr ;
571
578
if (ptr >= _inputEnd ) {
572
579
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
47
47
assertEquals ("abc\\ def" , result .id );
48
48
assertEquals ("Desc with\n linefeed" , result .desc );
49
49
}
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
+ }
51
62
}
You can’t perform that action at this time.
0 commit comments