aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDFWriter.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2019-06-09 23:19:07 +0200
committerJay Berkenbilt <ejb@ql.org>2019-06-09 23:19:49 +0200
commit31bde2f9d7517d3cf2433c2ea787eb9542532496 (patch)
treee471fe49dc981b87a7f25462a324c74c3a086697 /libqpdf/QPDFWriter.cc
parent74cc3440df7606c1e48bdbcb0ac5051fe0df0149 (diff)
downloadqpdf-31bde2f9d7517d3cf2433c2ea787eb9542532496.tar.zst
Handle empty DecodeParams array for (fixes #331)
On read, ignore /DecodeParms when empty list; on write, delete it. Some files have been found that include an empty list for /DecodeParms, but this is not technically compliant with the spec, and the only sensible interpretation is to treat it as if there are no decode parameters.
Diffstat (limited to 'libqpdf/QPDFWriter.cc')
-rw-r--r--libqpdf/QPDFWriter.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/libqpdf/QPDFWriter.cc b/libqpdf/QPDFWriter.cc
index fee287bc..0cc0547d 100644
--- a/libqpdf/QPDFWriter.cc
+++ b/libqpdf/QPDFWriter.cc
@@ -1604,6 +1604,14 @@ QPDFWriter::unparseObject(QPDFObjectHandle object, int level,
// Suppress /Length since we will write it manually
object.removeKey("/Length");
+ // If /DecodeParms is an empty list, remove it.
+ if (object.getKey("/DecodeParms").isArray() &&
+ (0 == object.getKey("/DecodeParms").getArrayNItems()))
+ {
+ QTC::TC("qpdf", "QPDFWriter remove empty DecodeParms");
+ object.removeKey("/DecodeParms");
+ }
+
if (flags & f_filtered)
{
// We will supply our own filter and decode