]> git.ipfire.org Git - thirdparty/json-c.git/commitdiff
Fix the apps/json_parse "-s" (strict) option so it actually does something, and defau...
authorEric Hawicz <erh+git@nimenees.com>
Mon, 4 Nov 2024 00:44:21 +0000 (19:44 -0500)
committerEric Hawicz <erh+git@nimenees.com>
Mon, 4 Nov 2024 00:44:21 +0000 (19:44 -0500)
apps/json_parse.c

index 31221d0e95aec221ed6e36c72aeba9600a650602..4eb629b154a63576c15e1f2a7aa5b142f6121cd8 100644 (file)
@@ -74,11 +74,14 @@ static int parseit(int fd, int (*callback)(struct json_object *))
                fprintf(stderr, "unable to allocate json_tokener: %s\n", strerror(errno));
                return 1;
        }
-       json_tokener_set_flags(tok, JSON_TOKENER_STRICT
-#ifdef JSON_TOKENER_ALLOW_TRAILING_CHARS
-                | JSON_TOKENER_ALLOW_TRAILING_CHARS
-#endif
-       );
+       if (strict_mode)
+       {
+               json_tokener_set_flags(tok, JSON_TOKENER_STRICT
+       #ifdef JSON_TOKENER_ALLOW_TRAILING_CHARS
+                        | JSON_TOKENER_ALLOW_TRAILING_CHARS
+       #endif
+               );
+       }
 
        // XXX push this into some kind of json_tokener_parse_fd API?
        //  json_object_from_fd isn't flexible enough, and mirroring