Commit Graph
1516 Commits
Author SHA1 Message Date
Afonso Januário 1b504e26ab json_patch: fix move/copy false rejection between sibling keys sharing a prefix
json_patch_apply_move_copy() checks that "from" is not a proper prefix
of "path" per RFC 6902 section 4.4 (a location cannot be moved into one
of its own children), but it did so with a plain strncmp() over the raw
pointer strings, without checking that the shared run of characters
actually ends on a JSON Pointer reference-token boundary in "path".

As a result, moving or copying between two sibling object keys where
one name is a textual prefix of the other, e.g. "/aa" to "/aab", was
rejected with "Invalid attempt to move parent under a child" even
though "/aa" is not an ancestor pointer of "/aab" at all, just an
unrelated key that happens to share a few leading characters.

The fix requires that the character in "path" right after the shared
"from" prefix be either the end of the string (equal paths, a no-op)
or a '/' (a genuine nested reference token), before treating it as an
attempt to move a location under its own descendant.

Added two cases to json_patch_tests.json covering the move and copy
operations between such sibling keys, and refreshed the corresponding
golden test_json_patch.expected output.
2026-09-25 23:52:49 +01:00
Eric Hawicz 25895a587e Instead of hardcoding the version into amiga/json-c.readme, generate it on the fly from either a release tag or a development version + commit hash. 2026-09-20 16:06:05 -04:00
Eric Hawicz 19980dbafd Merge pull request #963 from sacredbanana/fbaserel
Amiga enhancements: Build for more platforms + package for Aminet
2026-09-20 16:02:19 -04:00
Eric Hawicz fa774da301 Merge pull request #968 from 1234binpig/master
json_parse: report incomplete and failed input
2026-09-19 20:12:00 -04:00
Eric Hawicz a559871165 Merge pull request #971 from prownd/json_tokener-arraylist-assorted-cleanups-s01
json_tokener, arraylist: assorted cleanups
2026-09-14 23:14:06 -04:00
huangwenbin 0e5a2d43f7 json_parse returned success when input ended while the tokener was
still waiting for more data, and also after read() failures.

Finalize the tokener at EOF with the terminating NUL so valid scalar
values can complete, while rejecting genuinely truncated input.

Also propagate read errors to the caller and add CLI regression tests.
2026-09-14 15:23:04 +08:00
hanjinpeng 596c9d2d03 json_tokener, arraylist: assorted cleanups
json_tokener.c assigned to an int64_t through a (uint64_t) cast.  The
guarded range makes it harmless, but the cast names the wrong type.

array_list_expand_internal() reallocated when max == arr->size even though
the array can already hold max entries at that point, since callers only
index up to max - 1.  Skip the realloc.
2026-09-13 23:08:18 -04:00
Eric Hawicz a954bda619 Merge pull request #969 from hilbert149/docs
Documentation fixes
2026-09-12 09:40:11 -04:00
Eric Hawicz 694b912496 Merge pull request #970 from hilbert149/parseit
json_parse: Exit with error when reading the input fails
2026-09-12 09:39:00 -04:00
panzhe ea23279b75 json_parse: Exit with error when reading the input fails 2026-09-09 11:52:42 +08:00
panzhe 0dd8a021d7 Documentation fixes 2026-09-09 11:22:11 +08:00
Eric Hawicz 8381d33d78 Merge pull request #967 from hilbert149/exit_with_error
Fix json_parse:exit with error when input file cannot be opened
2026-09-07 07:56:02 -05:00
Eric Hawicz 18000a8e5a Merge pull request #966 from hilbert149/json_object_array_to_json_string
json_object_array_to_json_string: Hoist array length out of the loop
2026-09-07 07:55:03 -05:00
panzhe b11a9cd5fe json_object_array_to_json_string: Hoist array length out of the loop
json_object_array_length() was re-evaluated on every iteration.
Move it out of the loop to align with json_object_deep_copy_recursive().
2026-09-07 15:23:26 +08:00
panzhe 6c57831f03 Fix json_parse:exit with error when input file cannot be opened 2026-09-07 15:15:32 +08:00
Eric Hawicz 7760bce042 Merge pull request #965 from hilbert149/lseek-args
Fix swapped lseek() arguments
2026-09-06 22:51:47 -04:00
panzhe 5815babc4f Fix swapped lseek() arguments
lseek() expects (fd, offset, whence). The test passed (fd, SEEK_SET, 0),
which does not conform to the function signature. It should be corrected
to (fd, 0, SEEK_SET).
2026-09-07 09:58:09 +08:00
Eric Hawicz a0bfde7d02 Merge pull request #964 from hilbert149/master
Fix typo in json_object_iterator.h
2026-09-02 06:44:36 -04:00
panzhe 0fbd6ae464 Fix typo in json_object_iterator.h 2026-09-02 17:21:36 +08:00
Cameron Armstrong (Nightfox)andCursor 083d244d9a Address review feedback on the Amiga packaging PR.
Keep Amiga-specific files under amiga/, cache the pinned LHa binary in
CI, and make it explicit that the workflow artifact is not an official
release.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-30 23:28:43 +08:00
Eric Hawicz befb5a0b26 Merge pull request #961 from dxbjavid/pointer-set-unescape
decode ~1/~0 escapes when setting an object member in json_pointer
2026-08-30 10:22:42 -04:00
Eric Hawicz 697c6bfeb5 Merge pull request #962 from junkilee80/fix/object-add-key-leak
Fix object key leak on insertion failure
2026-08-30 10:20:29 -04:00
Cameron Armstrong (Nightfox) 385c46ef39 Add Amiga workflow 2026-08-24 03:14:08 +08:00
Cameron Armstrong (Nightfox) 6a273c567b add json-c directory to root of lha 2026-08-24 02:28:34 +08:00
Cameron Armstrong (Nightfox) 13778a9cb6 Update readme 2026-08-24 02:22:13 +08:00
Cameron Armstrong (Nightfox) 3ea3271978 Package for Amiga for publishing 2026-08-23 22:19:43 +08:00
Cameron Armstrong (Nightfox) a52110770c Update readme 2026-08-23 04:42:40 +08:00
Cameron Armstrong (Nightfox) f6881669c2 Specify fbaserel and Motorola CPU target 2026-08-22 14:47:19 +08:00
Javid Khan dcdea4e906 decode ~1/~0 escapes when setting an object member in json_pointer 2026-08-22 12:01:01 +05:30
Junki Lee 2094974201 Fix object key leak on insertion failure 2026-08-21 13:18:26 +09:00
Eric Hawicz d17ad9d186 Merge pull request #960 from Max13245/fix/test-json-parse-cli
Fix test_json_parse_cli
2026-08-20 21:27:31 -04:00
Max Rijkers 105a1067e3 Use printf instead of echo 2026-08-20 23:21:16 +02:00
Max Rijkers c80ca19a35 Only execute test_json_parse_cli when BUILD_APPS is ON 2026-08-20 23:19:38 +02:00
Eric Hawicz f4fd48cdea Merge pull request #958 from dxbjavid/uint64-negative-whitespace
reject negative after whitespace in json_parse_uint64
2026-08-20 09:36:43 -04:00
Javid Khan 510d68bd35 reject negative after whitespace in json_parse_uint64 2026-08-17 20:37:45 +05:30
Eric Hawicz 81092b3072 Merge pull request #948 from thesamesam/meson
meson: wire up `disable_extra_libs` option
2026-08-17 01:16:31 -04:00
Eric Hawicz 8319071e2b Merge pull request #957 from dngr2/fix/strict-number-grammar
Check the whole RFC 8259 number grammar in strict mode
2026-08-16 21:37:39 -04:00
Denis Gregor e222189360 Check the whole RFC 8259 number grammar in strict mode
Strict mode rejected leading zeros but nothing else about the shape of a
number, so several malformed numbers parsed and were then written back out
verbatim, producing JSON that other parsers reject:

    $ echo '[2.e3]' | ./json_parse -s -
    [ 2.e3 ]

RFC 8259 requires a mandatory integer part and at least one digit in both the
fraction and the exponent:

    number = [ minus ] int [ frac ] [ exp ]
    int    = zero / ( digit1-9 *DIGIT )
    frac   = decimal-point 1*DIGIT
    exp    = e [ minus / plus ] 1*DIGIT

so "1.", "-2.", "2.e3", "2.e+3", "0.e1", "-.123", "1e" and "1e+" are all
invalid. Walk the accumulated text against that grammar instead. The leading
zero rule from the previous check is part of the same walk rather than a
separate test, and its cases keep their coverage.

Only JSON_TOKENER_STRICT is affected; the default tokener stays as lenient as
it was. Measured against JSONTestSuite (318 files): strict mode went from 44
to 37 files accepted that the suite says must be rejected, default mode stayed
at 71, and nothing that must be accepted regressed in either mode.
2026-08-16 20:26:15 +03:00
Eric Hawicz 27bf659204 Merge the two meson checks for arc4random, instead have the has_function loop check first without, then with the dependencies. 2026-08-15 10:58:04 -04:00
Eric Hawicz 892c204ce0 Merge pull request #955 from carrerasdarren-cell/agent/fix-printbuf-self-append
printbuf: preserve self-append sources across growth
2026-08-15 10:10:20 -04:00
Darren Carreras 9782370c3f Address printbuf review comments 2026-08-09 20:01:12 -04:00
Eric Hawicz c0d4626175 Merge pull request #953 from dxbjavid/number-leading-zero-strict
reject leading zeros in strict-mode number parsing
2026-08-03 21:11:40 -04:00
Darren Carreras 62bb838c57 printbuf: preserve self-append sources across growth
When the appended data points into the printbuf itself, growing the buffer may invalidate the source pointer before it is copied. Preserve the source offset across realloc and use memmove for internal overlap.
2026-08-01 14:12:56 -04:00
Javid Khan ff18c75286 reject leading zeros in strict-mode number parsing 2026-07-28 13:27:25 +05:30
Tyler Erickson 133b0b8322 make: Fixing missing math dependency in non-Windows json-c builds with meson
The -lm was missing in the pkgconfig file that was generated. This adds that similar to the CMake build system's output.

Signed-off-by: Tyler Erickson <tyler.erickson@seagate.com>
Signed-off-by: Sam James <sam@gentoo.org>
2026-07-24 14:14:11 +01:00
Sam James 2419dbd2ea meson: fix pkgconfig file
Fix includedir and libdir to have proper paths (not just relative ones
to prefix).

Using Meson's native pkgconfig module is the best way of doing this.

Signed-off-by: Sam James <sam@gentoo.org>
2026-07-24 07:37:41 +01:00
Sam James 7ee487cc61 meson: fix version numbers
Signed-off-by: Sam James <sam@gentoo.org>
2026-07-24 07:37:41 +01:00
Sam James 87087ded64 meson: improve test handling
Tests will now be built at `meson test`-time, so there's no cost if the
user isn't going to run them.

This is better than guarding on build type, as distros may want to test production
builds before shipping.

Signed-off-by: Sam James <sam@gentoo.org>
2026-07-24 07:37:41 +01:00
Sam James cf958091ad meson: wire up extra_libs option
This is more elegant as a meson feature option because feature options
propagate in a useful way to `dependency(..., required: ...)`.

Without this, the option was ignored. Wiring it up naively meant that
disabling it still searched for libbsd as well, so a feature option
is the best fit.

Also, mark it as a dependency of `arc4random`.

Signed-off-by: Sam James <sam@gentoo.org>
2026-07-24 07:37:40 +01:00
Eric Hawicz 1bd2e4b3ef Merge pull request #949 from dxbjavid/pointer-empty-index-token
reject empty reference token as array index in json_pointer
2026-07-21 19:45:12 -04:00