mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-22 10:58:58 +00:00
Add data member JSONParser::token_start
This commit is contained in:
parent
39dfd305c8
commit
bb89a60320
@ -671,6 +671,7 @@ namespace
|
||||
qpdf_offset_t offset;
|
||||
bool done;
|
||||
std::string token;
|
||||
qpdf_offset_t token_start{0};
|
||||
parser_state_e parser_state;
|
||||
std::vector<std::shared_ptr<JSON>> stack;
|
||||
std::vector<parser_state_e> ps_stack;
|
||||
@ -863,6 +864,7 @@ JSONParser::getToken()
|
||||
action = append;
|
||||
switch (lex_state) {
|
||||
case ls_top:
|
||||
token_start = offset;
|
||||
if (*p == '"') {
|
||||
lex_state = ls_string;
|
||||
} else if (QUtil::is_space(*p)) {
|
||||
@ -1134,7 +1136,7 @@ JSONParser::handleToken()
|
||||
if (token.length() < 2) {
|
||||
throw std::logic_error("JSON string length < 2");
|
||||
}
|
||||
s_value = decode_string(token, offset - toO(token.length()));
|
||||
s_value = decode_string(token, token_start);
|
||||
}
|
||||
|
||||
std::shared_ptr<JSON> item;
|
||||
@ -1142,12 +1144,12 @@ JSONParser::handleToken()
|
||||
switch (lex_state) {
|
||||
case ls_begin_dict:
|
||||
item = std::make_shared<JSON>(JSON::makeDictionary());
|
||||
item->setStart(offset - toO(token.length()));
|
||||
item->setStart(token_start);
|
||||
break;
|
||||
|
||||
case ls_begin_array:
|
||||
item = std::make_shared<JSON>(JSON::makeArray());
|
||||
item->setStart(offset - toO(token.length()));
|
||||
item->setStart(token_start);
|
||||
break;
|
||||
|
||||
case ls_colon:
|
||||
@ -1296,7 +1298,7 @@ JSONParser::handleToken()
|
||||
}
|
||||
} else if (item.get()) {
|
||||
if (!(item->isArray() || item->isDictionary())) {
|
||||
item->setStart(offset - toO(token.length()));
|
||||
item->setStart(token_start);
|
||||
item->setEnd(offset);
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
WARNING: qjson-objects-not-dict.json (offset 82): "qpdf[1]" must be a dictionary
|
||||
WARNING: qjson-objects-not-dict.json (offset 81): "qpdf[1]" must be a dictionary
|
||||
WARNING: qjson-objects-not-dict.json: "qpdf[1].trailer" was not seen
|
||||
qpdf: qjson-objects-not-dict.json: errors found in JSON
|
||||
|
@ -1,3 +1,3 @@
|
||||
WARNING: qjson-stream-not-dict.json (obj:1 0 R, offset 123): "stream" must be a dictionary
|
||||
WARNING: qjson-stream-not-dict.json (obj:1 0 R, offset 122): "stream" must be a dictionary
|
||||
WARNING: qjson-stream-not-dict.json: "qpdf[1].trailer" was not seen
|
||||
qpdf: qjson-stream-not-dict.json: errors found in JSON
|
||||
|
@ -1,2 +1,2 @@
|
||||
WARNING: qjson-trailer-not-dict.json (trailer, offset 1269): "trailer.value" must be a dictionary
|
||||
WARNING: qjson-trailer-not-dict.json (trailer, offset 1268): "trailer.value" must be a dictionary
|
||||
qpdf: qjson-trailer-not-dict.json: errors found in JSON
|
||||
|
Loading…
Reference in New Issue
Block a user