diff options
author | Jay Berkenbilt <ejb@ql.org> | 2012-12-30 01:00:05 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2012-12-31 16:32:32 +0100 |
commit | 93ac1695a4b79f3d5b71e2d57ed876c28866d2c9 (patch) | |
tree | 7b202d0056fd5f1599a7ac0fe6c7cdf152440d0d /libqpdf/QPDF.cc | |
parent | eff2c9a67937b875d578b8a744070516f91930e2 (diff) | |
download | qpdf-93ac1695a4b79f3d5b71e2d57ed876c28866d2c9.tar.zst |
Support files with only attachments encrypted
Test cases added in a future commit since they depend on /R=6 support.
Diffstat (limited to 'libqpdf/QPDF.cc')
-rw-r--r-- | libqpdf/QPDF.cc | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc index 9d5d8240..bee8cde1 100644 --- a/libqpdf/QPDF.cc +++ b/libqpdf/QPDF.cc @@ -314,6 +314,7 @@ QPDF::parse(char const* password) } initializeEncryption(); + findAttachmentStreams(); } void @@ -2069,3 +2070,38 @@ QPDF::pipeStreamData(int objid, int generation, } pipeline->finish(); } + +void +QPDF::findAttachmentStreams() +{ + QPDFObjectHandle root = getRoot(); + QPDFObjectHandle names = root.getKey("/Names"); + if (! names.isDictionary()) + { + return; + } + QPDFObjectHandle embeddedFiles = names.getKey("/EmbeddedFiles"); + if (! embeddedFiles.isDictionary()) + { + return; + } + names = embeddedFiles.getKey("/Names"); + if (! names.isArray()) + { + return; + } + for (int i = 0; i < names.getArrayNItems(); ++i) + { + QPDFObjectHandle item = names.getArrayItem(i); + if (item.isDictionary() && + item.getKey("/Type").isName() && + (item.getKey("/Type").getName() == "/Filespec") && + item.getKey("/EF").isDictionary() && + item.getKey("/EF").getKey("/F").isStream()) + { + QPDFObjectHandle stream = item.getKey("/EF").getKey("/F"); + this->attachment_streams.insert( + ObjGen(stream.getObjectID(), stream.getGeneration())); + } + } +} |