mirror of
https://github.com/qpdf/qpdf.git
synced 2024-11-08 06:15:23 +00:00
In QPDFParser constructor add add parameter parse_pdf
Prepare for treating indirect references differently depending on whether we are parsing a PDF file (in which case reference to objects not in the xref table are null even if they are in the object cache) or whether parse from user code (in which case an indirect reference can refer to a user created object).
This commit is contained in:
parent
77d1a0cf24
commit
87ee8ad071
@ -1462,7 +1462,8 @@ QPDF::readTrailer()
|
||||
{
|
||||
qpdf_offset_t offset = m->file->tell();
|
||||
bool empty = false;
|
||||
auto object = QPDFParser(m->file, "trailer", m->tokenizer, nullptr, this).parse(empty, false);
|
||||
auto object =
|
||||
QPDFParser(m->file, "trailer", m->tokenizer, nullptr, this, true).parse(empty, false);
|
||||
if (empty) {
|
||||
// Nothing in the PDF spec appears to allow empty objects, but they have been encountered in
|
||||
// actual PDF files and Adobe Reader appears to ignore them.
|
||||
@ -1484,7 +1485,8 @@ QPDF::readObject(std::string const& description, QPDFObjGen og)
|
||||
|
||||
StringDecrypter decrypter{this, og};
|
||||
StringDecrypter* decrypter_ptr = m->encp->encrypted ? &decrypter : nullptr;
|
||||
auto object = QPDFParser(m->file, m->last_object_description, m->tokenizer, decrypter_ptr, this)
|
||||
auto object =
|
||||
QPDFParser(m->file, m->last_object_description, m->tokenizer, decrypter_ptr, this, true)
|
||||
.parse(empty, false);
|
||||
if (empty) {
|
||||
// Nothing in the PDF spec appears to allow empty objects, but they have been encountered in
|
||||
@ -1604,7 +1606,7 @@ QPDF::readObjectInStream(std::shared_ptr<InputSource>& input, int obj)
|
||||
m->last_object_description += " 0";
|
||||
|
||||
bool empty = false;
|
||||
auto object = QPDFParser(input, m->last_object_description, m->tokenizer, nullptr, this)
|
||||
auto object = QPDFParser(input, m->last_object_description, m->tokenizer, nullptr, this, true)
|
||||
.parse(empty, false);
|
||||
if (empty) {
|
||||
// Nothing in the PDF spec appears to allow empty objects, but they have been encountered in
|
||||
|
@ -2146,7 +2146,8 @@ QPDFObjectHandle::parseContentStream_data(
|
||||
tokenizer.readToken(input, "content", true);
|
||||
qpdf_offset_t offset = input->getLastOffset();
|
||||
input->seek(offset, SEEK_SET);
|
||||
auto obj = QPDFParser(input, "content", tokenizer, nullptr, context).parse(empty, true);
|
||||
auto obj =
|
||||
QPDFParser(input, "content", tokenizer, nullptr, context, false).parse(empty, true);
|
||||
if (!obj.isInitialized()) {
|
||||
// EOF
|
||||
break;
|
||||
@ -2205,7 +2206,8 @@ QPDFObjectHandle::parse(
|
||||
StringDecrypter* decrypter,
|
||||
QPDF* context)
|
||||
{
|
||||
return QPDFParser(input, object_description, tokenizer, decrypter, context).parse(empty, false);
|
||||
return QPDFParser(input, object_description, tokenizer, decrypter, context, false)
|
||||
.parse(empty, false);
|
||||
}
|
||||
|
||||
#ifndef QPDF_FUTURE
|
||||
|
@ -16,7 +16,8 @@ class QPDFParser
|
||||
std::string const& object_description,
|
||||
QPDFTokenizer& tokenizer,
|
||||
QPDFObjectHandle::StringDecrypter* decrypter,
|
||||
QPDF* context) :
|
||||
QPDF* context,
|
||||
bool parse_pdf) :
|
||||
input(input),
|
||||
object_description(object_description),
|
||||
tokenizer(tokenizer),
|
||||
|
Loading…
Reference in New Issue
Block a user