aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2019-04-20 23:47:51 +0200
committerJay Berkenbilt <ejb@ql.org>2019-04-21 03:00:43 +0200
commit4ccb29912a28e78b130091b8e66ccaa79c626ae7 (patch)
tree782aad1f1254dbebf4ff329e942e91d4e2ba5f44
parent131a21d36f68370c39b349b8c3628dac5ad8f73a (diff)
downloadqpdf-4ccb29912a28e78b130091b8e66ccaa79c626ae7.tar.zst
Tighten isPageObject (fixes #310)
-rw-r--r--ChangeLog9
-rw-r--r--libqpdf/QPDFObjectHandle.cc10
2 files changed, 14 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 5f464987..e62317b8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2019-04-20 Jay Berkenbilt <ejb@ql.org>
+ * Slightly tighten logic that determines whether an object is a
+ page. The previous logic was sometimes failing to preserve
+ annotations because they were passing the overly loose test for
+ whether something was a page. This fix has a slight risk of
+ causing some extraneous objects to be copied during page splitting
+ and merging for erroneous PDF files whose page objects contain
+ invalid types or are missing the /Type key entirely, both of which
+ would be invalid according to the PDF specification.
+
* Revert change that included preservation of outlines (bookmarks)
in --split-pages. The way it was implemented caused a very
significant performance penalty when splitting pages with
diff --git a/libqpdf/QPDFObjectHandle.cc b/libqpdf/QPDFObjectHandle.cc
index a3a4d61d..f7c78c57 100644
--- a/libqpdf/QPDFObjectHandle.cc
+++ b/libqpdf/QPDFObjectHandle.cc
@@ -2524,14 +2524,14 @@ QPDFObjectHandle::isPageObject()
return true;
}
// Files have been seen in the wild that have /Type (Page)
- if (type.isString() && (type.getStringValue() == "Page"))
+ else if (type.isString() && (type.getStringValue() == "Page"))
{
return true;
}
- }
- if (this->hasKey("/Contents"))
- {
- return true;
+ else
+ {
+ return false;
+ }
}
return false;
}