aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf
diff options
context:
space:
mode:
authorMasamichi Hosoda <trueroad@trueroad.jp>2019-09-27 14:00:30 +0200
committerJay Berkenbilt <ejb@ql.org>2019-10-22 22:16:16 +0200
commit06b818dcd39b5aeaeeee5c247483633a02a0222e (patch)
treed8547c0a002738368913b24685ffdb24b077ee3f /libqpdf
parent5e0ba126871c57a8a688b36614f2b8d78c2675b3 (diff)
downloadqpdf-06b818dcd39b5aeaeeee5c247483633a02a0222e.tar.zst
Exclude signature dictionary from compressible objects
It seems better not to compress signature dictionaries. Various PDF digital signing tools, including Adobe Acrobat Reader DC, do not compress signature dictionaries. Table 8.93 "Entries in a signature dictionary" in PDF 1.5 reference describes that /ByteRange in the signature dictionary shall be used to describe a digest that does not include the signature value (/Contents) itself. The byte ranges cannot be determined if the dictionary is compressed.
Diffstat (limited to 'libqpdf')
-rw-r--r--libqpdf/QPDF.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc
index c546fbe1..6c0c700a 100644
--- a/libqpdf/QPDF.cc
+++ b/libqpdf/QPDF.cc
@@ -2673,7 +2673,13 @@ QPDF::getCompressibleObjGens()
{
QTC::TC("qpdf", "QPDF exclude encryption dictionary");
}
- else if (! obj.isStream())
+ else if ((! obj.isStream()) &&
+ (! (obj.isDictionary() &&
+ obj.hasKey("/ByteRange") &&
+ obj.hasKey("/Contents") &&
+ obj.hasKey("/Type") &&
+ obj.getKey("/Type").isName() &&
+ obj.getKey("/Type").getName() == "/Sig")))
{
result.push_back(og);
}