2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-10-31 19:02:30 +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> 2013-01-22 Jay Berkenbilt <ejb@ql.org>
* Add QPDFObjectHandle::getTypeCode(). This method returns a * Add QPDFObjectHandle::getTypeCode(). This method returns a

View File

@ -46,6 +46,14 @@ struct QPDFPageData
std::vector<int> selected_pages; 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 // Note: let's not be too noisy about documenting the fact that this
// software purposely fails to enforce the distinction between user // software purposely fails to enforce the distinction between user
// and owner passwords. A user password is sufficient to gain full // and owner passwords. A user password is sufficient to gain full
@ -1442,6 +1450,8 @@ int main(int argc, char* argv[])
else else
{ {
std::cout << "File is not linearized\n"; std::cout << "File is not linearized\n";
}
// Write the file no nowhere, uncompressing // Write the file no nowhere, uncompressing
// streams. This causes full file traversal // streams. This causes full file traversal
// and decoding of all streams we can decode. // and decoding of all streams we can decode.
@ -1450,8 +1460,19 @@ int main(int argc, char* argv[])
w.setOutputPipeline(&discard); w.setOutputPipeline(&discard);
w.setStreamDataMode(qpdf_s_uncompress); w.setStreamDataMode(qpdf_s_uncompress);
w.write(); w.write();
okay = true;
// 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) catch (std::exception& e)
{ {