[PATCH jsonpath] main: fix array parsing

Mikael Magnusson mikma.lowo at lists.m7n.se
Thu May 20 12:44:50 PDT 2021


From: Mikael Magnusson <mikma at users.sourceforge.net>

Don't stop array parsing if the chunk happens to end at an object boundary.

Fixes FS#3683: jsonfilter yields unreliable results

Signed-off-by: Mikael Magnusson <mikma at users.sourceforge.net>
---
 main.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/main.c b/main.c
index 5041d10..1e3665e 100644
--- a/main.c
+++ b/main.c
@@ -146,8 +146,12 @@ parse_json(FILE *fd, const char *source, const char **error, bool array_mode)
 		{
 			obj = parse_json_chunk(tok, array, buf, len, &err);
 
-			if (err == json_tokener_success && !array)
-				break;
+			if (err == json_tokener_success) {
+				if (!array)
+					break;
+				else
+					continue;
+			}
 
 			if (err != json_tokener_continue)
 				break;
-- 
2.25.1




More information about the openwrt-devel mailing list