@@ -167,4 +167,62 @@ private void _testSingleQuotesEscaped(int mode) throws Exception
167
167
assertToken (JsonToken .END_ARRAY , p .nextToken ());
168
168
p .close ();
169
169
}
170
+
171
+ // [core#721]: specific issue with enclosed unescaped double quotes
172
+ public void testSingleQuotedKeys721 () throws Exception
173
+ {
174
+ // empty
175
+ _testSingleQuotedKeys721 ("{ '\" \" ': 'value'}" , "\" \" " );
176
+ // non-empty
177
+ _testSingleQuotedKeys721 ("{ '\" key\" ': 'value'}" , "\" key\" " );
178
+ }
179
+
180
+ private void _testSingleQuotedKeys721 (String doc , String expKey ) throws Exception
181
+ {
182
+ _testSingleQuotedKeys721 (MODE_READER , doc , expKey );
183
+ _testSingleQuotedKeys721 (MODE_INPUT_STREAM , doc , expKey );
184
+ _testSingleQuotedKeys721 (MODE_INPUT_STREAM_THROTTLED , doc , expKey );
185
+ _testSingleQuotedKeys721 (MODE_DATA_INPUT , doc , expKey );
186
+ }
187
+
188
+ private void _testSingleQuotedKeys721 (int mode , String doc , String expKey ) throws Exception
189
+ {
190
+ JsonParser p = createParser (APOS_F , mode , doc );
191
+
192
+ assertToken (JsonToken .START_OBJECT , p .nextToken ());
193
+ assertEquals (expKey , p .nextFieldName ());
194
+ assertToken (JsonToken .VALUE_STRING , p .nextToken ());
195
+ assertEquals ("value" , p .getText ());
196
+ assertToken (JsonToken .END_OBJECT , p .nextToken ());
197
+ p .close ();
198
+ }
199
+
200
+ // [core#721]: specific issue with enclosed unescaped double quotes
201
+ public void testSingleQuotedValues721 () throws Exception
202
+ {
203
+ // empty
204
+ _testSingleQuotedValues721 ("{ \" bar\" : '\" \" '}" , "\" \" " );
205
+ // non-empty
206
+ _testSingleQuotedValues721 ("{ \" bar\" : '\" stuff\" '}" , "\" stuff\" " );
207
+ }
208
+
209
+ private void _testSingleQuotedValues721 (String doc , String expValue ) throws Exception
210
+ {
211
+ _testSingleQuotedValues721 (MODE_READER , doc , expValue );
212
+ _testSingleQuotedValues721 (MODE_INPUT_STREAM , doc , expValue );
213
+ _testSingleQuotedValues721 (MODE_INPUT_STREAM_THROTTLED , doc , expValue );
214
+ _testSingleQuotedValues721 (MODE_DATA_INPUT , doc , expValue );
215
+ }
216
+
217
+ private void _testSingleQuotedValues721 (int mode , String doc , String expValue ) throws Exception
218
+ {
219
+ JsonParser p = createParser (APOS_F , mode , doc );
220
+
221
+ assertToken (JsonToken .START_OBJECT , p .nextToken ());
222
+ assertEquals ("bar" , p .nextFieldName ());
223
+ assertToken (JsonToken .VALUE_STRING , p .nextToken ());
224
+ assertEquals (expValue , p .getText ());
225
+ assertToken (JsonToken .END_OBJECT , p .nextToken ());
226
+ p .close ();
227
+ }
170
228
}
0 commit comments