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)
34
34
* Suggested #56: Support comments (either via `CsvSchema`, or using std
35
35
`JsonParser.Feature.ALLOW_YAML_COMMENTS.
36
36
(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
4
4
=== Releases ===
5
5
------------------------------------------------------------------------
6
6
7
+ 2.5.3 (not yet released)
8
+
9
+ #75: Support escapes at beginning of the file
10
+ (contributed by David N)
11
+
7
12
2.5.2 (29-Mar-2015)
8
13
9
14
#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
632
632
outBuf [0 ] = (char ) i ;
633
633
int outPtr = 1 ;
634
634
635
+ if (i == _escapeChar ) {
636
+ // Reset the escaped character
637
+ outBuf [0 ] = _unescape ();
638
+ return _nextUnquotedString (outBuf , outPtr );
639
+ }
640
+
635
641
int ptr = _inputPtr ;
636
642
if (ptr >= _inputEnd ) {
637
643
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
51
51
assertEquals ("Desc with\n linefeed" , result .desc );
52
52
}
53
53
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
+ }
54
65
}
You can’t perform that action at this time.
0 commit comments