mirror of
https://github.com/qpdf/qpdf.git
synced 2025-01-08 17:24:06 +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;
|
qpdf_offset_t offset;
|
||||||
bool done;
|
bool done;
|
||||||
std::string token;
|
std::string token;
|
||||||
|
qpdf_offset_t token_start{0};
|
||||||
parser_state_e parser_state;
|
parser_state_e parser_state;
|
||||||
std::vector<std::shared_ptr<JSON>> stack;
|
std::vector<std::shared_ptr<JSON>> stack;
|
||||||
std::vector<parser_state_e> ps_stack;
|
std::vector<parser_state_e> ps_stack;
|
||||||
@ -863,6 +864,7 @@ JSONParser::getToken()
|
|||||||
action = append;
|
action = append;
|
||||||
switch (lex_state) {
|
switch (lex_state) {
|
||||||
case ls_top:
|
case ls_top:
|
||||||
|
token_start = offset;
|
||||||
if (*p == '"') {
|
if (*p == '"') {
|
||||||
lex_state = ls_string;
|
lex_state = ls_string;
|
||||||
} else if (QUtil::is_space(*p)) {
|
} else if (QUtil::is_space(*p)) {
|
||||||
@ -1134,7 +1136,7 @@ JSONParser::handleToken()
|
|||||||
if (token.length() < 2) {
|
if (token.length() < 2) {
|
||||||
throw std::logic_error("JSON string 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;
|
std::shared_ptr<JSON> item;
|
||||||
@ -1142,12 +1144,12 @@ JSONParser::handleToken()
|
|||||||
switch (lex_state) {
|
switch (lex_state) {
|
||||||
case ls_begin_dict:
|
case ls_begin_dict:
|
||||||
item = std::make_shared<JSON>(JSON::makeDictionary());
|
item = std::make_shared<JSON>(JSON::makeDictionary());
|
||||||
item->setStart(offset - toO(token.length()));
|
item->setStart(token_start);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ls_begin_array:
|
case ls_begin_array:
|
||||||
item = std::make_shared<JSON>(JSON::makeArray());
|
item = std::make_shared<JSON>(JSON::makeArray());
|
||||||
item->setStart(offset - toO(token.length()));
|
item->setStart(token_start);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ls_colon:
|
case ls_colon:
|
||||||
@ -1296,7 +1298,7 @@ JSONParser::handleToken()
|
|||||||
}
|
}
|
||||||
} else if (item.get()) {
|
} else if (item.get()) {
|
||||||
if (!(item->isArray() || item->isDictionary())) {
|
if (!(item->isArray() || item->isDictionary())) {
|
||||||
item->setStart(offset - toO(token.length()));
|
item->setStart(token_start);
|
||||||
item->setEnd(offset);
|
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
|
WARNING: qjson-objects-not-dict.json: "qpdf[1].trailer" was not seen
|
||||||
qpdf: qjson-objects-not-dict.json: errors found in JSON
|
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
|
WARNING: qjson-stream-not-dict.json: "qpdf[1].trailer" was not seen
|
||||||
qpdf: qjson-stream-not-dict.json: errors found in JSON
|
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
|
qpdf: qjson-trailer-not-dict.json: errors found in JSON
|
||||||
|
Loading…
Reference in New Issue
Block a user