2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-22 10:58:58 +00:00

Have qpdf --check parse content streams

Also move writing to null and parsing of content streams out of the
wrong if block.
This commit is contained in:
Jay Berkenbilt 2013-01-24 10:47:29 -05:00
parent 34311a89c5
commit a7e8b8c789
2 changed files with 42 additions and 10 deletions

View File

@ -1,3 +1,14 @@
2013-01-24 Jay Berkenbilt <ejb@ql.org>
* qpdf --check now does syntactic checks all pages' content
streams as well as checking overall document structure. Semantic
errors are still not checked, and there are no plans to add
semantic checks.
* Bug fix: in versions 4.0.0 and 4.0.1, qpdf --check wasn't doing
as full of a check for linearized files as for non-linearized
files.
2013-01-22 Jay Berkenbilt <ejb@ql.org>
* Add QPDFObjectHandle::getTypeCode(). This method returns a

View File

@ -46,6 +46,14 @@ struct QPDFPageData
std::vector<int> selected_pages;
};
class DiscardContents: public QPDFObjectHandle::ParserCallbacks
{
public:
virtual ~DiscardContents() {}
virtual void handleObject(QPDFObjectHandle) {}
virtual void handleEOF() {}
};
// Note: let's not be too noisy about documenting the fact that this
// software purposely fails to enforce the distinction between user
// and owner passwords. A user password is sufficient to gain full
@ -1442,16 +1450,29 @@ int main(int argc, char* argv[])
else
{
std::cout << "File is not linearized\n";
// Write the file no nowhere, uncompressing
// streams. This causes full file traversal
// and decoding of all streams we can decode.
QPDFWriter w(pdf);
Pl_Discard discard;
w.setOutputPipeline(&discard);
w.setStreamDataMode(qpdf_s_uncompress);
w.write();
okay = true;
}
}
// Write the file no nowhere, uncompressing
// streams. This causes full file traversal
// and decoding of all streams we can decode.
QPDFWriter w(pdf);
Pl_Discard discard;
w.setOutputPipeline(&discard);
w.setStreamDataMode(qpdf_s_uncompress);
w.write();
// Parse all content streams
std::vector<QPDFObjectHandle> pages = pdf.getAllPages();
DiscardContents discard_contents;
for (std::vector<QPDFObjectHandle>::iterator iter =
pages.begin();
iter != pages.end(); ++iter)
{
QPDFObjectHandle::parseContentStream(
(*iter).getKey("/Contents"), &discard_contents);
}
okay = true;
}
catch (std::exception& e)
{