diff options
author | Jay Berkenbilt <ejb@ql.org> | 2012-12-30 19:54:12 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2012-12-31 16:32:32 +0100 |
commit | 9a23c3dcb675a62e6a8b144304bdc91cae365c4c (patch) | |
tree | ec387d1265ed6aa660133a887f1b59055dcdde5e /qpdf/test_driver.cc | |
parent | 4237a29c9492653e1be869d603e1b5bf87833682 (diff) | |
download | qpdf-9a23c3dcb675a62e6a8b144304bdc91cae365c4c.tar.zst |
Remove /Crypt from stream filters unconditionally
When writing a new stream, always remove /Crypt even if we are not
otherwise able to filter the stream.
Diffstat (limited to 'qpdf/test_driver.cc')
-rw-r--r-- | qpdf/test_driver.cc | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/qpdf/test_driver.cc b/qpdf/test_driver.cc index 45190042..239464ce 100644 --- a/qpdf/test_driver.cc +++ b/qpdf/test_driver.cc @@ -112,7 +112,7 @@ void runtest(int n, char const* filename1, char const* arg2) { pdf.setAttemptRecovery(false); } - if ((n == 35) && (arg2 != 0)) + if (((n == 35) || (n == 36)) && (arg2 != 0)) { // arg2 is password pdf.processFile(filename1, arg2); @@ -1214,6 +1214,37 @@ void runtest(int n, char const* filename1, char const* arg2) std::cout << filename << ":\n" << data << "--END--\n"; } } + else if (n == 36) + { + // Extract raw unfilterable attachment + + QPDFObjectHandle root = pdf.getRoot(); + QPDFObjectHandle names = root.getKey("/Names"); + QPDFObjectHandle embeddedFiles = names.getKey("/EmbeddedFiles"); + names = embeddedFiles.getKey("/Names"); + 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() && + (item.getKey("/F").getStringValue() == "attachment1.txt")) + { + std::string filename = item.getKey("/F").getStringValue(); + QPDFObjectHandle stream = item.getKey("/EF").getKey("/F"); + Pl_Buffer p1("buffer"); + Pl_Flate p2("compress", &p1, Pl_Flate::a_inflate); + stream.pipeStreamData(&p2, false, false, false); + PointerHolder<Buffer> buf = p1.getBuffer(); + std::string data = std::string( + (char const*)buf->getBuffer(), buf->getSize()); + std::cout << stream.getDict().unparse() + << filename << ":\n" << data << "--END--\n"; + } + } + } else { throw std::runtime_error(std::string("invalid test ") + |