mirror of
https://github.com/qpdf/qpdf.git
synced 2025-01-24 07:38:28 +00:00
Make JSONParser::getToken responsible for decoding strings
This commit is contained in:
parent
126dd31cad
commit
a9a0667904
@ -1052,6 +1052,9 @@ JSONParser::getToken()
|
|||||||
|
|
||||||
case ls_string:
|
case ls_string:
|
||||||
if (*p == '"') {
|
if (*p == '"') {
|
||||||
|
token += '"';
|
||||||
|
token = decode_string(token, token_start);
|
||||||
|
action = ignore;
|
||||||
ready = true;
|
ready = true;
|
||||||
} else if (*p == '\\') {
|
} else if (*p == '\\') {
|
||||||
lex_state = ls_backslash;
|
lex_state = ls_backslash;
|
||||||
@ -1146,7 +1149,6 @@ JSONParser::handleToken()
|
|||||||
": material follows end of object: " + token);
|
": material follows end of object: " + token);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string s_value;
|
|
||||||
std::shared_ptr<JSON> item;
|
std::shared_ptr<JSON> item;
|
||||||
auto tos = stack.empty() ? nullptr : stack.back().item;
|
auto tos = stack.empty() ? nullptr : stack.back().item;
|
||||||
auto ls = lex_state;
|
auto ls = lex_state;
|
||||||
@ -1245,19 +1247,14 @@ JSONParser::handleToken()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case ls_string:
|
case ls_string:
|
||||||
// Token includes the quotation marks
|
|
||||||
if (token.length() < 2) {
|
|
||||||
throw std::logic_error("JSON string length < 2");
|
|
||||||
}
|
|
||||||
s_value = decode_string(token, token_start);
|
|
||||||
if (parser_state == ps_dict_begin ||
|
if (parser_state == ps_dict_begin ||
|
||||||
parser_state == ps_dict_after_comma) {
|
parser_state == ps_dict_after_comma) {
|
||||||
dict_key = s_value;
|
dict_key = token;
|
||||||
dict_key_offset = token_start;
|
dict_key_offset = token_start;
|
||||||
parser_state = ps_dict_after_key;
|
parser_state = ps_dict_after_key;
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
item = std::make_shared<JSON>(JSON::makeString(s_value));
|
item = std::make_shared<JSON>(JSON::makeString(token));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user