mirror of
https://github.com/json-c/json-c.git
synced 2026-09-07 08:36:50 +08:00
reject leading zeros in strict-mode number parsing
This commit is contained in:
@@ -366,6 +366,15 @@ struct incremental_step
|
||||
{"12{", 3, 2, json_tokener_success, 1, 0},
|
||||
/* Parse number in strict mode */
|
||||
{"[02]", -1, 3, json_tokener_error_parse_number, 1, JSON_TOKENER_STRICT},
|
||||
/* Leading zeros are rejected in strict mode, for every sign and type ... */
|
||||
{"[00]", -1, 3, json_tokener_error_parse_number, 1, JSON_TOKENER_STRICT},
|
||||
{"[-00]", -1, 4, json_tokener_error_parse_number, 1, JSON_TOKENER_STRICT},
|
||||
{"[-01]", -1, 4, json_tokener_error_parse_number, 1, JSON_TOKENER_STRICT},
|
||||
{"[-0123]", -1, 6, json_tokener_error_parse_number, 1, JSON_TOKENER_STRICT},
|
||||
{"[01.5]", -1, 5, json_tokener_error_parse_number, 1, JSON_TOKENER_STRICT},
|
||||
/* ... but a lone zero, "-0" and a zero before the fraction stay valid. */
|
||||
{"[-0]", -1, -1, json_tokener_success, 1, JSON_TOKENER_STRICT},
|
||||
{"[0.5]", -1, -1, json_tokener_success, 1, JSON_TOKENER_STRICT},
|
||||
|
||||
{"0e+0", 5, 4, json_tokener_success, 1, 0},
|
||||
{"[0e+0]", -1, -1, json_tokener_success, 1, 0},
|
||||
|
||||
@@ -156,6 +156,13 @@ 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, [00] , 4) ... OK: got correct error: number expected
|
||||
json_tokener_parse_ex(tok, [-00] , 5) ... OK: got correct error: number expected
|
||||
json_tokener_parse_ex(tok, [-01] , 5) ... OK: got correct error: number expected
|
||||
json_tokener_parse_ex(tok, [-0123] , 7) ... OK: got correct error: number expected
|
||||
json_tokener_parse_ex(tok, [01.5] , 6) ... OK: got correct error: number expected
|
||||
json_tokener_parse_ex(tok, [-0] , 4) ... OK: got object of type [array]: [ 0 ]
|
||||
json_tokener_parse_ex(tok, [0.5] , 5) ... OK: got object of type [array]: [ 0.5 ]
|
||||
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
|
||||
@@ -368,5 +375,5 @@ json_tokener_parse_ex(tok, {"":1} , 7) ... OK: got correct error: invalid
|
||||
json_tokener_parse_ex(tok, {"":1} , 7) ... OK: got correct error: invalid string sequence
|
||||
json_tokener_parse_ex(tok, {"":1} , 7) ... OK: got correct error: invalid string sequence
|
||||
json_tokener_parse_ex(tok, {"":1} , 7) ... OK: got correct error: invalid string sequence
|
||||
End Incremental Tests OK=272 ERROR=0
|
||||
End Incremental Tests OK=279 ERROR=0
|
||||
==================================
|
||||
|
||||
Reference in New Issue
Block a user