diff options
author | Jay Berkenbilt <ejb@ql.org> | 2021-03-01 23:34:47 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2021-03-03 23:05:49 +0100 |
commit | a15ec6967dd3312223a6ab7d4198655234e1a4bf (patch) | |
tree | 1b0ebb6a44c4c527d6594c9c79fe9b2bef065299 /libqpdf | |
parent | 1bb209a9bf5ade164cf1ba7c3b9399be70c45c24 (diff) | |
download | qpdf-a15ec6967dd3312223a6ab7d4198655234e1a4bf.tar.zst |
Enhancements to ParserCallbacks
Diffstat (limited to 'libqpdf')
-rw-r--r-- | libqpdf/QPDFObjectHandle.cc | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/libqpdf/QPDFObjectHandle.cc b/libqpdf/QPDFObjectHandle.cc index 6d4f10ce..35a4962a 100644 --- a/libqpdf/QPDFObjectHandle.cc +++ b/libqpdf/QPDFObjectHandle.cc @@ -152,6 +152,16 @@ QPDFObjectHandle::ParserCallbacks::handleObject( } void +QPDFObjectHandle::ParserCallbacks::handleWarning() +{ +} + +void +QPDFObjectHandle::ParserCallbacks::handleEOF() +{ +} + +void QPDFObjectHandle::ParserCallbacks::contentSize(size_t) { // Ignore by default; overriding this is optional. @@ -1847,10 +1857,15 @@ QPDFObjectHandle::parseContentStream_internal( pipeContentStreams(&buf, description, all_description); PointerHolder<Buffer> stream_data = buf.getBuffer(); callbacks->contentSize(stream_data->getSize()); + QPDF* context = getOwningQPDF(); + if ((! context) && isArray() && (getArrayNItems() > 0)) + { + context = getArrayItem(0).getOwningQPDF(); + } try { parseContentStream_data(stream_data, all_description, - callbacks, getOwningQPDF()); + callbacks, context); } catch (TerminateParsing&) { @@ -1881,9 +1896,15 @@ QPDFObjectHandle::parseContentStream_data( tokenizer.readToken(input, "content", true); qpdf_offset_t offset = input->getLastOffset(); input->seek(offset, SEEK_SET); + size_t before_nwarnings = (context ? context->numWarnings() : 0); QPDFObjectHandle obj = parseInternal(input, "content", tokenizer, empty, 0, context, true); + size_t after_nwarnings = (context ? context->numWarnings() : 0); + if (after_nwarnings > before_nwarnings) + { + callbacks->handleWarning(); + } if (! obj.isInitialized()) { // EOF @@ -1910,6 +1931,7 @@ QPDFObjectHandle::parseContentStream_data( QPDFExc(qpdf_e_damaged_pdf, input->getName(), "stream data", input->tell(), "EOF found while reading inline image")); + callbacks->handleWarning(); } else { |