Skip to content
This repository has been archived by the owner on Jan 22, 2019. It is now read-only.

Commit

Permalink
Backport #75 in 2.5(.3)
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Apr 15, 2015
1 parent 5e5ecfa commit 3492030
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
9 changes: 8 additions & 1 deletion release-notes/CREDITS
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,11 @@ Luke Nezda (nezda@github)
* Suggested #56: Support comments (either via `CsvSchema`, or using std
`JsonParser.Feature.ALLOW_YAML_COMMENTS.
(requested by nezda@github)
(2.5.0)
(2.5.0)

David Navas (davidnavas@github)

* Contributed #75: Support escapes at beginning of the file
(2.5.3)


5 changes: 5 additions & 0 deletions release-notes/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Project: jackson-dataformat-csv
=== Releases ===
------------------------------------------------------------------------

2.5.3 (not yet released)

#75: Support escapes at beginning of the file
(contributed by David N)

2.5.2 (29-Mar-2015)

#66: Deserializing an empty string as an array field return a non-empty list of one empty String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,12 @@ public String nextString() throws IOException
outBuf[0] = (char) i;
int outPtr = 1;

if (i == _escapeChar) {
// Reset the escaped character
outBuf[0] = _unescape();
return _nextUnquotedString(outBuf, outPtr);
}

int ptr = _inputPtr;
if (ptr >= _inputEnd) {
if (!loadMore()) { // ok to have end-of-input but...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,15 @@ public void testSimpleEscapesInUnquoted() throws Exception
assertEquals("Desc with\nlinefeed", result.desc);
}

public void testEscapesAtStartInUnquoted() throws Exception
{
CsvMapper mapper = mapperForCsv();
CsvSchema schema = mapper.schemaFor(Desc.class).withColumnSeparator('|').withEscapeChar('\\');
final String id = "\\|abcdef"; // doubled for javac
final String desc = "Desc with\\\nlinefeed";
String input = id+"|"+desc+"\n";
Desc result = mapper.reader(schema).withType(Desc.class).readValue(input);
assertEquals("|abcdef", result.id);
assertEquals("Desc with\nlinefeed", result.desc);
}
}

0 comments on commit 3492030

Please sign in to comment.