Skip to content

Commit 23b6899

Browse files
committed
Merge branch '2.10' into 2.11
2 parents db1401a + b83ab88 commit 23b6899

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

src/test/java/com/fasterxml/jackson/databind/ObjectReaderTest.java

+31-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public void testReaderForMapOf() throws Exception
8989
assertEquals(Collections.singletonMap("key", ABC.B), value);
9090
}
9191

92-
public void testParserFeatures() throws Exception
92+
public void testParserFeaturesComments() throws Exception
9393
{
9494
final String JSON = "[ /* foo */ 7 ]";
9595
// default won't accept comments, let's change that:
@@ -110,6 +110,36 @@ public void testParserFeatures() throws Exception
110110
}
111111
}
112112

113+
public void testParserFeaturesCtrlChars() throws Exception
114+
{
115+
String FIELD = "a\tb";
116+
String VALUE = "\t";
117+
String JSON = "{ "+quote(FIELD)+" : "+quote(VALUE)+"}";
118+
Map<?, ?> result;
119+
120+
// First: by default, unescaped control characters should not work
121+
try {
122+
result = MAPPER.readValue(JSON, Map.class);
123+
fail("Should not pass with defaylt settings");
124+
} catch (JsonParseException e) {
125+
verifyException(e, "Illegal unquoted character");
126+
}
127+
128+
// But both ObjectReader:
129+
result = MAPPER.readerFor(Map.class)
130+
.with(JsonReadFeature.ALLOW_UNESCAPED_CONTROL_CHARS)
131+
.readValue(JSON);
132+
assertEquals(1, result.size());
133+
134+
// and new mapper should work
135+
ObjectMapper mapper2 = JsonMapper.builder()
136+
.enable(JsonReadFeature.ALLOW_UNESCAPED_CONTROL_CHARS)
137+
.build();
138+
result = mapper2.readerFor(Map.class)
139+
.readValue(JSON);
140+
assertEquals(1, result.size());
141+
}
142+
113143
public void testNodeHandling() throws Exception
114144
{
115145
JsonNodeFactory nodes = new JsonNodeFactory(true);

0 commit comments

Comments
 (0)