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
This commit is contained in:
Eric Haszlakiewicz
2020-06-27 15:32:19 +00:00
parent 84e6032883
commit 6eac6986c9
6 changed files with 120 additions and 17 deletions

View File

@@ -145,6 +145,25 @@ json_tokener_parse_ex(tok, 1 , 1) ... OK: got correct error: continu
json_tokener_parse_ex(tok, 2 , 2) ... OK: got object of type [int]: 12
json_tokener_parse_ex(tok, 12{ , 3) ... OK: got object of type [int]: 12
json_tokener_parse_ex(tok, [02] , 4) ... OK: got correct error: number expected
json_tokener_parse_ex(tok, 0e+0 , 5) ... OK: got object of type [double]: 0e+0
json_tokener_parse_ex(tok, [0e+0] , 6) ... OK: got object of type [array]: [ 0e+0 ]
json_tokener_parse_ex(tok, 0e , 2) ... OK: got correct error: continue
json_tokener_parse_ex(tok, 0e , 3) ... OK: got object of type [double]: 0
json_tokener_parse_ex(tok, 0e , 3) ... OK: got correct error: unexpected end of data
json_tokener_parse_ex(tok, [0e] , 4) ... OK: got object of type [array]: [ 0 ]
json_tokener_parse_ex(tok, [0e] , 4) ... OK: got correct error: number expected
json_tokener_parse_ex(tok, 0e+ , 3) ... OK: got correct error: continue
json_tokener_parse_ex(tok, 0e+ , 4) ... OK: got object of type [double]: 0
json_tokener_parse_ex(tok, 0e+ , 4) ... OK: got correct error: unexpected end of data
json_tokener_parse_ex(tok, [0e+] , 5) ... OK: got object of type [array]: [ 0 ]
json_tokener_parse_ex(tok, [0e+] , 5) ... OK: got correct error: number expected
json_tokener_parse_ex(tok, 0e- , 3) ... OK: got correct error: continue
json_tokener_parse_ex(tok, 0e- , 4) ... OK: got object of type [double]: 0
json_tokener_parse_ex(tok, 0e- , 4) ... OK: got correct error: unexpected end of data
json_tokener_parse_ex(tok, [0e-] , 5) ... OK: got object of type [array]: [ 0 ]
json_tokener_parse_ex(tok, [0e-] , 5) ... OK: got correct error: number expected
json_tokener_parse_ex(tok, 0e+- , 5) ... OK: got correct error: number expected
json_tokener_parse_ex(tok, [0e+-] , 6) ... OK: got correct error: number expected
json_tokener_parse_ex(tok, false , 5) ... OK: got correct error: continue
json_tokener_parse_ex(tok, false , 6) ... OK: got object of type [boolean]: false
json_tokener_parse_ex(tok, true , 4) ... OK: got correct error: continue
@@ -246,5 +265,5 @@ json_tokener_parse_ex(tok, "\ud855
json_tokener_parse_ex(tok, "\ud0031<33>" , 10) ... OK: got correct error: invalid utf-8 string
json_tokener_parse_ex(tok, 11<31>11 , 5) ... OK: got correct error: invalid utf-8 string
json_tokener_parse_ex(tok, {"1<>":1} , 8) ... OK: got correct error: invalid utf-8 string
End Incremental Tests OK=160 ERROR=0
End Incremental Tests OK=179 ERROR=0
==================================