From 40f00122b811ca5c8788856f5baf4e5e088926eb Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Wed, 26 Jul 2017 14:38:49 -0400 Subject: Convert object parsing errors to warnings QPDFObjectHandle::parseInternal now issues warnings instead of throwing exceptions for all error conditions that it finds (except internal logic errors) and has stronger recovery for things like invalid tokens and malformed dictionaries. This should improve qpdf's ability to recover from a wide range of broken files that currently cause it to fail. --- include/qpdf/QPDF.hh | 12 ++++++++++++ include/qpdf/QPDFObjectHandle.hh | 4 ++++ 2 files changed, 16 insertions(+) (limited to 'include') diff --git a/include/qpdf/QPDF.hh b/include/qpdf/QPDF.hh index 4742275f..0788316d 100644 --- a/include/qpdf/QPDF.hh +++ b/include/qpdf/QPDF.hh @@ -522,6 +522,18 @@ class QPDF }; friend class Resolver; + // Warner class allows QPDFObjectHandle to create warnings + class Warner + { + friend class QPDFObjectHandle; + private: + static void warn(QPDF* qpdf, QPDFExc const& e) + { + qpdf->warn(e); + } + }; + friend class Warner; + // Pipe class is restricted to QPDF_Stream class Pipe { diff --git a/include/qpdf/QPDFObjectHandle.hh b/include/qpdf/QPDFObjectHandle.hh index bd1f1f19..0fc989a5 100644 --- a/include/qpdf/QPDFObjectHandle.hh +++ b/include/qpdf/QPDFObjectHandle.hh @@ -28,6 +28,7 @@ class QPDF; class QPDF_Dictionary; class QPDF_Array; class QPDFTokenizer; +class QPDFExc; class QPDFObjectHandle { @@ -623,6 +624,9 @@ class QPDFObjectHandle static void parseContentStream_internal( QPDFObjectHandle stream, ParserCallbacks* callbacks); + // Other methods + static void warn(QPDF*, QPDFExc const&); + bool initialized; QPDF* qpdf; // 0 for direct object -- cgit v1.2.3-70-g09d2