mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-22 02:49:00 +00:00
In JSONParser add lex_state ls_number_e_sign
This commit is contained in:
parent
04333bbc20
commit
6ea543e6c7
@ -653,6 +653,7 @@ namespace
|
||||
ls_number_point,
|
||||
ls_number_after_point,
|
||||
ls_number_e,
|
||||
ls_number_e_sign,
|
||||
ls_alpha,
|
||||
ls_string,
|
||||
ls_backslash,
|
||||
@ -988,6 +989,14 @@ JSONParser::getToken()
|
||||
++number_after_e;
|
||||
lex_state = ls_number;
|
||||
} else if ((*p == '+') || (*p == '-')) {
|
||||
lex_state = ls_number_e_sign;
|
||||
} else {
|
||||
numberError();
|
||||
}
|
||||
break;
|
||||
|
||||
case ls_number_e_sign:
|
||||
if ((*p >= '0') && (*p <= '9')) {
|
||||
lex_state = ls_number;
|
||||
} else {
|
||||
numberError();
|
||||
@ -1120,13 +1129,14 @@ JSONParser::getToken()
|
||||
throw std::logic_error("tok_start set in ls_top while parsing");
|
||||
break;
|
||||
|
||||
case ls_number:
|
||||
case ls_number_minus:
|
||||
case ls_number_leading_zero:
|
||||
case ls_number_before_point:
|
||||
case ls_number_point:
|
||||
case ls_number_after_point:
|
||||
case ls_number_e:
|
||||
case ls_number:
|
||||
case ls_number_minus:
|
||||
case ls_number_leading_zero:
|
||||
case ls_number_e_sign:
|
||||
case ls_alpha:
|
||||
// okay
|
||||
break;
|
||||
@ -1206,6 +1216,7 @@ JSONParser::handleToken()
|
||||
case ls_number_point:
|
||||
case ls_number_after_point:
|
||||
case ls_number_e:
|
||||
case ls_number_e_sign:
|
||||
if (number_saw_point && (number_after_point == 0)) {
|
||||
// QTC::TC("libtests", "JSON parse decimal with no digits");
|
||||
throw std::runtime_error(
|
||||
|
@ -123,6 +123,8 @@ my @bad = (
|
||||
"duplicate dictionary key", # 40
|
||||
"decimal point after minus",# 41
|
||||
"e after minus", # 42
|
||||
"missing digit after e", # 43
|
||||
"missing digit after e+/-", # 44
|
||||
);
|
||||
|
||||
my $i = 0;
|
||||
|
1
libtests/qtest/json_parse/bad-43.json
Normal file
1
libtests/qtest/json_parse/bad-43.json
Normal file
@ -0,0 +1 @@
|
||||
123e
|
1
libtests/qtest/json_parse/bad-43.out
Normal file
1
libtests/qtest/json_parse/bad-43.out
Normal file
@ -0,0 +1 @@
|
||||
exception: bad-43.json: JSON: offset 4: numeric literal: incomplete number
|
1
libtests/qtest/json_parse/bad-44.json
Normal file
1
libtests/qtest/json_parse/bad-44.json
Normal file
@ -0,0 +1 @@
|
||||
123e+
|
1
libtests/qtest/json_parse/bad-44.out
Normal file
1
libtests/qtest/json_parse/bad-44.out
Normal file
@ -0,0 +1 @@
|
||||
exception: bad-44.json: JSON: offset 5: numeric literal: incomplete number
|
Loading…
Reference in New Issue
Block a user