aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorm-holger <m-holger@kubitscheck.org>2023-01-27 18:13:06 +0100
committerm-holger <m-holger@kubitscheck.org>2023-02-04 15:06:26 +0100
commitcee746fc154e82df43f427b4e6112fcb50070814 (patch)
treeea974034337259cf5c460e632bc8bce4a857b6f5
parenta9a0667904b467a054b5f7747bc16afba2612d7f (diff)
downloadqpdf-cee746fc154e82df43f427b4e6112fcb50070814.tar.zst
In JSONParser::getToken avoid copying '"' characters in strings
-rw-r--r--libqpdf/JSON.cc10
1 files changed, 2 insertions, 8 deletions
diff --git a/libqpdf/JSON.cc b/libqpdf/JSON.cc
index c043d570..51617483 100644
--- a/libqpdf/JSON.cc
+++ b/libqpdf/JSON.cc
@@ -744,14 +744,8 @@ JSONParser::decode_string(std::string const& str, qpdf_offset_t offset)
// is called, so errors are logic errors instead of runtime
// errors.
size_t len = str.length();
- if ((len < 2) || (str.at(0) != '"') || (str.at(len - 1) != '"')) {
- throw std::logic_error(
- "JSON Parse: decode_string called with other than \"...\"");
- }
char const* s = str.c_str();
- // Move inside the quotation marks
- ++s;
- len -= 2;
+
// Keep track of UTF-16 surrogate pairs.
unsigned long high_surrogate = 0;
qpdf_offset_t high_offset = 0;
@@ -878,6 +872,7 @@ JSONParser::getToken()
token_start = offset;
if (*p == '"') {
lex_state = ls_string;
+ action = ignore;
} else if (QUtil::is_space(*p)) {
action = ignore;
} else if (*p == ',') {
@@ -1052,7 +1047,6 @@ JSONParser::getToken()
case ls_string:
if (*p == '"') {
- token += '"';
token = decode_string(token, token_start);
action = ignore;
ready = true;