Add a JSON_TOKENER_ALLOW_TRAILING_CHARS flag for json_tokener_set_flags() to allow multiple objects to be parsed from input even when JSON_TOKENER_STRICT is set.

This commit is contained in:
Eric Haszlakiewicz
2020-04-20 16:06:34 +00:00
parent 05623b3a2e
commit f6f76f9430
5 changed files with 28 additions and 4 deletions

View File

@@ -25,7 +25,6 @@
#include <stdlib.h>
#include <string.h>
#include "arraylist.h"
#include "debug.h"
#include "json_inttypes.h"
#include "json_object.h"
@@ -1130,7 +1129,7 @@ out:
tok->err = json_tokener_error_parse_utf8_string;
}
if (c && (state == json_tokener_state_finish) && (tok->depth == 0) &&
(tok->flags & JSON_TOKENER_STRICT))
(tok->flags & (JSON_TOKENER_STRICT|JSON_TOKENER_ALLOW_TRAILING_CHARS)) == JSON_TOKENER_STRICT)
{
/* unexpected char after JSON data */
tok->err = json_tokener_error_parse_unexpected;