2
1
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:
m-holger 2023-01-24 13:04:31 +00:00
parent 04333bbc20
commit 6ea543e6c7
6 changed files with 20 additions and 3 deletions

View File

@ -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(

View File

@ -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;

View File

@ -0,0 +1 @@
123e

View File

@ -0,0 +1 @@
exception: bad-43.json: JSON: offset 4: numeric literal: incomplete number

View File

@ -0,0 +1 @@
123e+

View File

@ -0,0 +1 @@
exception: bad-44.json: JSON: offset 5: numeric literal: incomplete number