Eric Haszlakiewicz
d6f46ae104
Explicitly check for integer overflow/underflow when parsing integers with JSON_TOKENER_STRICT.
2 years ago
Tobias Stoeckmann
cbc603b587
Adjusted URLs
Most of these sites support HTTPS (some forward to HTTPS when accessing
the HTTP versions). Use HTTPS directly if supported.
Some URLs led to 404 error pages. Adjusted the links to point to
new locations.
I did not adjust the Microsoft HTML Help Workshop link because it seems
that this software is not available anymore. Instead of removing the
link entirely I kept it there in case it helps someone to find the
software on archived websites.
3 years ago
Even Rouault
3bb54f97e7
Fix typos in code comments and ChangeLog
3 years ago
Juuso Alasuutari
9361d8d3a8
Fix use-after-free in json_tokener_new_ex()
The failure path taken in the event of printbuf_new() returning NULL
calls free() on tok->stack after already having freed tok. Swap the
order of the two calls to fix an obvious memory access violation.
Fixes: bcb6d7d347
("Handle allocation failure in json_tokener_new_ex")
Signed-off-by: Juuso Alasuutari <juuso.alasuutari@gmail.com>
4 years ago
Eric Haszlakiewicz
f61f1a7a91
Add workaround for Visual Studio not knowing about "inline".
4 years ago
Eric Haszlakiewicz
6a0df2609e
Merge some old work to include (some of) PR #464 into the current master branch.
4 years ago
Tobias Stoeckmann
bcb6d7d347
Handle allocation failure in json_tokener_new_ex
The allocation of printbuf_new might fail. Return NULL to indicate tis
error to the caller. Otherwise later usage of the returned tokener would
lead to null pointer dereference.
5 years ago
Eric Haszlakiewicz
8c7849e6e3
Eliminate use of ctype.h and replace isdigit() and tolower() with non-locale-sensitive approaches.
5 years ago
Eric Haszlakiewicz
f3d8006d34
Neither vertical tab nor formfeed are considered whitespace per the JSON spec, remove them from is_ws_char().
5 years ago
Eric Haszlakiewicz
8b43ff0c22
Merge the is_ws_char() and is_hex_char() changes to json_tokener from branch 'ramiropolla/for_upstream' (PR #464 )
5 years ago
Pascal Cuoq
1962ba7de3
Fixes #645
5 years ago
Eric Haszlakiewicz
a4e3700972
Fix code formatting
5 years ago
Eric Haszlakiewicz
f23486a321
In the json_tokener_state_number case, explicitly adjust what "number" characters are allowed based on the exact micro-state that we're in, and check for invalid following characters in a different way, to allow a valid json_type_number object to be returned at the top level.
This causes previously failing strings like "123-456" to return a valid json_object with the appropriate value. If you care about the trailing content, call json_tokener_parse_ex() and check the parse end point with json_tokener_get_parse_end().
5 years ago
Eric Haszlakiewicz
6eac6986c9
Fix incremental parsing of invalid numbers with exponents, such as "0e+-" and "12.3E12E12", while still allowing "0e+" in non-strict mode.
Deprecate the json_parse_double() function from json_util.h
5 years ago
Eric Haszlakiewicz
84e6032883
Issue #635 : Fix "expression has no effect" warning in json_tokener.c by casting to void.
5 years ago
Eric Haszlakiewicz
a68566bf6a
Issue #616 : Change the parsing of surrogate pairs in unicode escapes so it uses a couple of additional states instead of assuming the low surrogate is already present, to ensure that we correctly handle various cases of incremental parsing.
5 years ago
Eric Haszlakiewicz
36118b681e
Rearrange the json_tokener_state_escape_unicode case in json_tokener to simplify the code slightly and make it a bit easier to understand.
While here, drop the utf8_replacement_char that is unnecesarily added if we run out of input in the middle of a unicode escape. No other functional changes (yet).
5 years ago
Eric Hawicz
da76ee26e7
Merge pull request #633 from dota17/issue616
fix issue 616: support the surrogate pair in split file.
5 years ago
Eric Haszlakiewicz
e26a1195f4
Add json_object_array_shrink() (and array_list_shrink()) and use it in json_tokener to minimize the amount of memory used. This results in a 39%-50% reduction in memory use (peak RSS, peak heap usage) on the jc-bench benchmark and 9% shorter runtime.
Also add the json_object_new_array_ext, array_list_new2, and array_list_shrink functions.
5 years ago
dota17
c1b872d817
fix issue 616: support the surrogate pair in split file.
5 years ago
David McCann
add7b13a9a
Improved support for IBM operating systems
Fix compiler errors and warnings when building on IBM operating systems such as AIX and IBM i.
5 years ago
Eric Haszlakiewicz
f6f76f9430
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.
5 years ago
Eric Haszlakiewicz
ecb9354bb1
Re-do clang-format.
5 years ago
Eric Haszlakiewicz
5cc11289b4
Make json_tokener_validate_utf8() internal to json_tokener.c, and improve the docs a bit.
5 years ago
dota17
8b162c4b89
clang-format the files
5 years ago
dota17
c117d8a8a8
add the disabling formatting coments and adjust the partial code manuly
5 years ago
dota17
3c3b5920f7
add uint64 data to json-c
5 years ago
dota17
787a8b3f1c
update code
5 years ago
dota17
eca74dcccf
test utf8
5 years ago
Eric Haszlakiewicz
374ffe87c6
Issue #463 : fix newlocale() call to use LC_NUMERIC_MASK instead of LC_NUMERIC, and remove incorrect comment.
The second call to newlocale() with LC_TIME accidentally made things
work because LC_TIME == LC_NUMERIC_MASK on some platforms.
6 years ago
Eric Haszlakiewicz
05b41b159e
Add a json_tokener_get_parse_end() function to replace direct access of tok->char_offset.
6 years ago
Ramiro Polla
c9a0ac5886
json_tokener: optimize parsing of integer values
speedup for 32-bit: ~8%
speedup for 64-bit: ~9%
6 years ago
Ramiro Polla
d98fc501fb
json_tokener: optimize check for number characters
speedup for 32-bit: ~5%
speedup for 64-bit: ~3%
6 years ago
Ramiro Polla
45c601bfa4
json_tokener: optimize check for hex characters
speedup for 32-bit: ~1%
speedup for 64-bit: ~1%
6 years ago
Ramiro Polla
158c248d5c
json_tokener: optimize check for whitespace characters
speedup for 32-bit: ~15%
speedup for 64-bit: ~ 2%
6 years ago
Eric Haszlakiewicz
f8c632f579
Issue #407 : fix incorrect casts in calls to ctype functions (isdigit and isspace) so we don't crash when asserts are enabled on certain platforms and characters > 128 are parsed.
7 years ago
Eric Haszlakiewicz
11ab365324
Deprecated a few typedefs, add docs on json_object_iter, move json_number_chars and json_hex-chars to json_object_private.h.
7 years ago
Eric Haszlakiewicz
0e7ec2ffcd
Add cast to int on tolower() to fix warnings about array subscripts.
7 years ago
Eric Haszlakiewicz
f81da5e57a
Rewrite the json_tokener_state_inf handling in json_tokener to be simpler, and avoid needless copying of the input into a temporary buffer.
7 years ago
Eric Haszlakiewicz
48f7e389fb
Fix parsing of "-Infinity" when the "-" and "Infinity" are split across multiple calls.
Add several additional test cases for partial parsing of infinity values.
7 years ago
Eric Haszlakiewicz
4d1e0b4409
Issue #371 : fix parsing of "-Infinity" (although in a somewhat different location than PR#372 used), and add a case to test_parse to check for this.
7 years ago
Haffon
b301f4ea01
rollback api to 0.12
8 years ago
Haffon
3141c3976b
1.make it can been compiled with Visual Studio 2010
2.replace json_object_get/put API with json_object_retain/release, as they operate the reference counter, and confused with array_list_get/put_idx.
3.replace array_list_get/put_idx API with array_list_get/insert to make them more clear to use.
8 years ago
marxin
014924ba89
Add FALLTHRU comment to handle GCC7 warnings.
8 years ago
Alexandru Ardelean
8cb86a583a
strdup_compat.h: re-spin this compat header ; use math_compat.h as template
Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
9 years ago
Emmanuele Bassi
7601f20d70
Revert "compat/strdup.h: move common compat check for strdup() to own file"
This reverts commit aaba8c1080
.
This commit breaks builddir != srcdir build, but, more importantly, it
also adds a dependency on a header, "config.h", which is not installed
and it's supposed to be private — since it's generated at configuration
time and it's not meant to be used by projects compiling against a
library.
9 years ago
Alexandru Ardelean
aaba8c1080
compat/strdup.h: move common compat check for strdup() to own file
Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
9 years ago
Eric Haszlakiewicz
36a28fcb0c
Issue #275 : fix out of bounds read when handling unicode surrogate pairs.
9 years ago
Eric Haszlakiewicz
4d62de3898
Revert bogus change to json_object_get() made in f40b08d8
that caused it to always return NULL. (Issue #259 )
Also undo NULL check in json_tokener_set_flags(): it's not at all valid toi
try to set flags on a NULL pointer, and doing so should not be silently
ignored.
9 years ago
Nicola Spanti (RyDroid)
f40b08d8f0
Minor changes in C source code
9 years ago