aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDFPageObjectHelper.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2018-06-22 16:45:31 +0200
committerJay Berkenbilt <ejb@ql.org>2018-06-22 16:45:31 +0200
commitc71dc6888c69aea7a892b313e07dba377200a6c9 (patch)
treeb04fdd17c80c9f3c6c80c07110055134f4f24cf1 /libqpdf/QPDFPageObjectHelper.cc
parent38c9ed23c3d05c6c217db287ae15c97498a69dd7 (diff)
downloadqpdf-c71dc6888c69aea7a892b313e07dba377200a6c9.tar.zst
Don't prune resource dictionaries on errors or by request
If we are unable to filter a page's content streams, don't attempt to remove objects from the page's resource dictionary. Also provide a command line option to suppress resource removal in case we ever need this as a workaround for some bug or broken PDF files.
Diffstat (limited to 'libqpdf/QPDFPageObjectHelper.cc')
-rw-r--r--libqpdf/QPDFPageObjectHelper.cc12
1 files changed, 11 insertions, 1 deletions
diff --git a/libqpdf/QPDFPageObjectHelper.cc b/libqpdf/QPDFPageObjectHelper.cc
index e9e09d73..4093622d 100644
--- a/libqpdf/QPDFPageObjectHelper.cc
+++ b/libqpdf/QPDFPageObjectHelper.cc
@@ -122,7 +122,17 @@ void
QPDFPageObjectHelper::removeUnreferencedResources()
{
NameWatcher nw;
- filterPageContents(&nw);
+ try
+ {
+ filterPageContents(&nw);
+ }
+ catch (std::exception& e)
+ {
+ this->oh.warnIfPossible(
+ std::string("Unable to parse content stream: ") + e.what() +
+ "; not attempting to remove unreferenced objects from this page");
+ return;
+ }
// Walk through /Font and /XObject dictionaries, removing any
// resources that are not referenced. We must make copies of
// resource dictionaries down into the dictionaries are mutating