mirror of
https://github.com/qpdf/qpdf.git
synced 2025-01-22 22:58:33 +00:00
In QPDFParser::parse refactor handling of array_open and dict_open tokens
This commit is contained in:
parent
90829228b8
commit
d904eab84c
@ -227,20 +227,15 @@ QPDFParser::parse(bool& empty, bool content_stream)
|
||||
if (stack.size() > 500) {
|
||||
QTC::TC("qpdf", "QPDFParser too deep");
|
||||
warn("ignoring excessively deeply nested data structure");
|
||||
if (tooManyBadTokens()) {
|
||||
return {QPDF_Null::create()};
|
||||
}
|
||||
is_null = true;
|
||||
state = st_top;
|
||||
return {QPDF_Null::create()};
|
||||
} else {
|
||||
state = st_start;
|
||||
state_stack.push_back(
|
||||
(tokenizer.getType() == QPDFTokenizer::tt_array_open) ? st_array
|
||||
: st_dictionary);
|
||||
b_contents = false;
|
||||
stack.emplace_back(input);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
|
||||
case QPDFTokenizer::tt_bool:
|
||||
object = QPDF_Bool::create((tokenizer.getValue() == "true"));
|
||||
@ -349,7 +344,7 @@ QPDFParser::parse(bool& empty, bool content_stream)
|
||||
break;
|
||||
}
|
||||
|
||||
if (object == nullptr && !is_null && state != st_start) {
|
||||
if (object == nullptr && !is_null) {
|
||||
throw std::logic_error("QPDFParser:parseInternal: unexpected uninitialized object");
|
||||
}
|
||||
|
||||
@ -369,9 +364,6 @@ QPDFParser::parse(bool& empty, bool content_stream)
|
||||
case st_top:
|
||||
done = true;
|
||||
break;
|
||||
|
||||
case st_start:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ class QPDFParser
|
||||
QPDFObjectHandle parse(bool& empty, bool content_stream);
|
||||
|
||||
private:
|
||||
enum parser_state_e { st_top, st_start, st_dictionary, st_array };
|
||||
enum parser_state_e { st_top, st_dictionary, st_array };
|
||||
|
||||
bool tooManyBadTokens();
|
||||
void warn(qpdf_offset_t offset, std::string const& msg) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user