aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/qpdf-c.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2017-07-26 20:38:49 +0200
committerJay Berkenbilt <ejb@ql.org>2017-07-28 00:20:31 +0200
commit40f00122b811ca5c8788856f5baf4e5e088926eb (patch)
tree3a8247e134b7624932cd5d1b29110eda39664d5a /libqpdf/qpdf-c.cc
parentdd8dad74f47b6068281dd605a04bc2d0b6283423 (diff)
downloadqpdf-40f00122b811ca5c8788856f5baf4e5e088926eb.tar.zst
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.
Diffstat (limited to 'libqpdf/qpdf-c.cc')
-rw-r--r--libqpdf/qpdf-c.cc10
1 files changed, 9 insertions, 1 deletions
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;
}