Commit 716a6c2
Fix decode_pointer_inplace ~1 escape and minify_string escape handling
Two bugs fixed:
1. cJSON_Utils.c decode_pointer_inplace(): The ~1 JSON Pointer escape
(RFC 6901 §3) was writing to decoded_string[1] instead of
decoded_string[0], causing incorrect decoding. Additionally,
non-escape characters after escape sequences were not being copied
when the decoded output pointer fell behind the input pointer.
This caused JSON Patch operations with ~1 in paths to silently
fail or operate on wrong keys.
2. cJSON.c minify_string(): The escape handling only checked for \"
(escaped quote) but not \\ (escaped backslash) or other escapes.
A string ending with \\ caused the closing quote to be
misidentified as an escaped quote, making the function read past
the string boundary and absorb subsequent JSON tokens into the
string value.
Both fixes are minimal and include bounds checking. All 19 existing
tests pass with these changes.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent b2890c8 commit 716a6c2
2 files changed
+6
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2913 | 2913 | | |
2914 | 2914 | | |
2915 | 2915 | | |
2916 | | - | |
| 2916 | + | |
2917 | 2917 | | |
2918 | 2918 | | |
2919 | 2919 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
374 | 374 | | |
375 | 375 | | |
376 | 376 | | |
377 | | - | |
| 377 | + | |
378 | 378 | | |
379 | 379 | | |
380 | 380 | | |
| |||
384 | 384 | | |
385 | 385 | | |
386 | 386 | | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
387 | 391 | | |
388 | 392 | | |
389 | 393 | | |
| |||
0 commit comments