File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -265,7 +265,7 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok,
265265 if ((!ADVANCE_CHAR (str , tok )) || (!PEEK_CHAR (c , tok )))
266266 goto out ;
267267 }
268- if (c == '/' ) {
268+ if (c == '/' && !( tok -> flags & JSON_TOKENER_STRICT ) ) {
269269 printbuf_reset (tok -> pb );
270270 printbuf_memappend_fast (tok -> pb , & c , 1 );
271271 state = json_tokener_state_comment_start ;
@@ -293,8 +293,13 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok,
293293 printbuf_reset (tok -> pb );
294294 tok -> st_pos = 0 ;
295295 goto redo_char ;
296- case '"' :
297296 case '\'' :
297+ if (tok -> flags & JSON_TOKENER_STRICT ) {
298+ /* in STRICT mode only double-quote are allowed */
299+ tok -> err = json_tokener_error_parse_unexpected ;
300+ goto out ;
301+ }
302+ case '"' :
298303 state = json_tokener_state_string ;
299304 printbuf_reset (tok -> pb );
300305 tok -> quote_char = c ;
@@ -764,6 +769,13 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok,
764769 } /* while(POP_CHAR) */
765770
766771 out :
772+ if (c &&
773+ (state == json_tokener_state_finish ) &&
774+ (tok -> depth == 0 ) &&
775+ (tok -> flags & JSON_TOKENER_STRICT )) {
776+ /* unexpected char after JSON data */
777+ tok -> err = json_tokener_error_parse_unexpected ;
778+ }
767779 if (!c ) { /* We hit an eof char (0) */
768780 if (state != json_tokener_state_finish &&
769781 saved_state != json_tokener_state_finish )
You can’t perform that action at this time.
0 commit comments