@@ -89,7 +89,7 @@ public void testReaderForMapOf() throws Exception
89
89
assertEquals (Collections .singletonMap ("key" , ABC .B ), value );
90
90
}
91
91
92
- public void testParserFeatures () throws Exception
92
+ public void testParserFeaturesComments () throws Exception
93
93
{
94
94
final String JSON = "[ /* foo */ 7 ]" ;
95
95
// default won't accept comments, let's change that:
@@ -110,6 +110,36 @@ public void testParserFeatures() throws Exception
110
110
}
111
111
}
112
112
113
+ public void testParserFeaturesCtrlChars () throws Exception
114
+ {
115
+ String FIELD = "a\t b" ;
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
+
113
143
public void testNodeHandling () throws Exception
114
144
{
115
145
JsonNodeFactory nodes = new JsonNodeFactory (true );
0 commit comments