aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDF_Stream.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2018-02-03 03:16:40 +0100
committerJay Berkenbilt <ejb@ql.org>2018-02-19 03:05:47 +0100
commit5136238f2a973f693cea53c340dcff23a655531f (patch)
tree8cc1d2a1fdf1833fa67454b2707994b3328c879c /libqpdf/QPDF_Stream.cc
parent30709935af023dd66a17f2d494aa7dc84b7177e1 (diff)
downloadqpdf-5136238f2a973f693cea53c340dcff23a655531f.tar.zst
Detect and report bad tokens in content normalization
Diffstat (limited to 'libqpdf/QPDF_Stream.cc')
-rw-r--r--libqpdf/QPDF_Stream.cc27
1 files changed, 27 insertions, 0 deletions
diff --git a/libqpdf/QPDF_Stream.cc b/libqpdf/QPDF_Stream.cc
index a026f9a4..bb1e24e6 100644
--- a/libqpdf/QPDF_Stream.cc
+++ b/libqpdf/QPDF_Stream.cc
@@ -609,6 +609,33 @@ QPDF_Stream::pipeStreamData(Pipeline* pipeline,
}
}
+ if (filter &&
+ (! suppress_warnings) &&
+ normalizer.getPointer() &&
+ normalizer->anyBadTokens())
+ {
+ warn(QPDFExc(qpdf_e_damaged_pdf, qpdf->getFilename(),
+ "", this->offset,
+ "content normalization encountered bad tokens"));
+ if (normalizer->lastTokenWasBad())
+ {
+ QTC::TC("qpdf", "QPDF_Stream bad token at end during normalize");
+ warn(QPDFExc(qpdf_e_damaged_pdf, qpdf->getFilename(),
+ "", this->offset,
+ "normalized content ended with a bad token;"
+ " you may be able to resolve this by"
+ " coalescing content streams in combination"
+ " with normalizing content. From the command"
+ " line, specify --coalesce-contents"));
+ }
+ warn(QPDFExc(qpdf_e_damaged_pdf, qpdf->getFilename(),
+ "", this->offset,
+ "Resulting stream data may be corrupted but is"
+ " may still useful for manual inspection."
+ " For more information on this warning, search"
+ " for content normalization in the manual."));
+ }
+
return filter;
}