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. --- libqpdf/qpdf-c.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'libqpdf/qpdf-c.cc') diff --git a/libqpdf/qpdf-c.cc b/libqpdf/qpdf-c.cc index c8adb9e4..975e9707 100644 --- a/libqpdf/qpdf-c.cc +++ b/libqpdf/qpdf-c.cc @@ -261,7 +261,15 @@ QPDF_ERROR_CODE qpdf_read(qpdf_data qpdf, char const* filename, qpdf->filename = filename; qpdf->password = password; status = trap_errors(qpdf, &call_read); - QTC::TC("qpdf", "qpdf-c called qpdf_read", status); + // We no longer have a good way to exercise a file with both + // warnings and errors because qpdf is getting much better at + // recovering. + QTC::TC("qpdf", "qpdf-c called qpdf_read", + (status == 0) ? 0 + : (status & QPDF_WARNINGS) ? 1 + : (status & QPDF_ERRORS) ? 2 : + -1 + ); return status; } -- cgit v1.2.3-54-g00ecf