diff --git a/ChangeLog b/ChangeLog index ba03fe89..283cd8cc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,11 @@ * Add C API function qpdf_oh_free_buffer to release memory allocated by stream data functions. +2024-09-19 M Holger + + * Bug fix: QPDFWriter stream DecodeLevel incorrectly defaulted to + none instead of generalied. Fixes #1286. + 2024-08-25 M Holger * Add new command-line arguments --remove-metadata and --remove-info diff --git a/libqpdf/QPDFWriter.cc b/libqpdf/QPDFWriter.cc index 4dda1dc0..7b8daf5b 100644 --- a/libqpdf/QPDFWriter.cc +++ b/libqpdf/QPDFWriter.cc @@ -2126,7 +2126,7 @@ QPDFWriter::doWriteSetup() if (m->encrypted) { // Encryption has been explicitly set m->preserve_encryption = false; - } else if (m->normalize_content || m->stream_decode_level || m->pclm || m->qdf_mode) { + } else if (m->normalize_content || !m->compress_streams || m->pclm || m->qdf_mode) { // Encryption makes looking at contents pretty useless. If the user explicitly encrypted // though, we still obey that. m->preserve_encryption = false; diff --git a/libqpdf/qpdf/QPDFWriter_private.hh b/libqpdf/qpdf/QPDFWriter_private.hh index 5a46d907..cbb667fd 100644 --- a/libqpdf/qpdf/QPDFWriter_private.hh +++ b/libqpdf/qpdf/QPDFWriter_private.hh @@ -65,7 +65,7 @@ class QPDFWriter::Members bool normalize_content{false}; bool compress_streams{true}; bool compress_streams_set{false}; - qpdf_stream_decode_level_e stream_decode_level{qpdf_dl_none}; + qpdf_stream_decode_level_e stream_decode_level{qpdf_dl_generalized}; bool stream_decode_level_set{false}; bool recompress_flate{false}; bool qdf_mode{false}; diff --git a/qpdf/qtest/encryption.test b/qpdf/qtest/encryption.test index 9263602e..3173dbbb 100644 --- a/qpdf/qtest/encryption.test +++ b/qpdf/qtest/encryption.test @@ -723,7 +723,7 @@ $td->runtest("check file's validity", $td->runtest("handle missing/invalid Length", {$td->COMMAND => "qpdf --check bad-encryption-length.pdf"}, {$td->FILE => "bad-encryption-length.out", - $td->EXIT_STATUS => 0}, + $td->EXIT_STATUS => 3}, $td->NORMALIZE_NEWLINES); cleanup(); diff --git a/qpdf/qtest/inline-images.test b/qpdf/qtest/inline-images.test index 20388da5..05af5d68 100644 --- a/qpdf/qtest/inline-images.test +++ b/qpdf/qtest/inline-images.test @@ -56,7 +56,7 @@ $td->runtest("externalize damaged image", "qpdf --externalize-inline-images" . " --compress-streams=n --static-id" . " damaged-inline-image.pdf a.pdf"}, - {$td->STRING => "", $td->EXIT_STATUS => 0}, + {$td->FILE => "damaged-inline-image.out", $td->EXIT_STATUS => 3}, $td->NORMALIZE_NEWLINES); $td->runtest("check output", {$td->FILE => "a.pdf"}, diff --git a/qpdf/qtest/qpdf/bad-encryption-length.out b/qpdf/qtest/qpdf/bad-encryption-length.out index a29eb13e..5648fda6 100644 --- a/qpdf/qtest/qpdf/bad-encryption-length.out +++ b/qpdf/qtest/qpdf/bad-encryption-length.out @@ -14,5 +14,5 @@ modify annotations: allowed modify other: allowed modify anything: allowed File is not linearized -No syntax or stream encoding errors found; the file may still contain -errors that qpdf cannot detect +WARNING: bad-encryption-length.pdf, object 7 0 at offset 531 -> dictionary key /Length: operation for integer attempted on object of type null: returning 0 +qpdf: operation succeeded with warnings diff --git a/qpdf/qtest/qpdf/damaged-inline-image.out b/qpdf/qtest/qpdf/damaged-inline-image.out new file mode 100644 index 00000000..f870017d --- /dev/null +++ b/qpdf/qtest/qpdf/damaged-inline-image.out @@ -0,0 +1,3 @@ +WARNING: damaged-inline-image.pdf, stream object 8 0: error while getting stream data: stream inflate: inflate: data: invalid distance too far back +WARNING: damaged-inline-image.pdf, stream object 8 0: qpdf will attempt to write the damaged stream unchanged +qpdf: operation succeeded with warnings; resulting file may have some problems diff --git a/qpdf/qtest/qpdf/fuzz-16214.out b/qpdf/qtest/qpdf/fuzz-16214.out index a03574be..040592ff 100644 --- a/qpdf/qtest/qpdf/fuzz-16214.out +++ b/qpdf/qtest/qpdf/fuzz-16214.out @@ -6,6 +6,11 @@ WARNING: fuzz-16214.pdf (xref stream, offset 116): Cross-reference stream data h WARNING: fuzz-16214.pdf: reported number of objects (6) is not one plus the highest object number (35) WARNING: fuzz-16214.pdf (object 14 0, offset 652): expected dictionary key but found non-name object; inserting key /QPDFFake1 WARNING: fuzz-16214.pdf (object 14 0, offset 734): expected endobj +WARNING: fuzz-16214.pdf (object 15 0, offset 869): unknown token while reading object; treating as string +WARNING: fuzz-16214.pdf (object 15 0, offset 745): expected dictionary key but found non-name object; inserting key /QPDFFake1 +WARNING: fuzz-16214.pdf (object 15 0, offset 894): expected endobj +WARNING: fuzz-16214.pdf, object 15 0 at offset 745: kid 0 (from 0) MediaBox is undefined; setting to letter / ANSI A +WARNING: fuzz-16214.pdf, object 15 0 at offset 745: /Type key should be /Page but is not; overriding WARNING: fuzz-16214.pdf: file is damaged WARNING: fuzz-16214.pdf (object 1 0, offset 7189): expected n n obj WARNING: fuzz-16214.pdf: Attempting to reconstruct cross-reference table diff --git a/qpdf/qtest/qpdf/invalid-id-xref.out b/qpdf/qtest/qpdf/invalid-id-xref.out index c8e7eefc..cbfa67e7 100644 --- a/qpdf/qtest/qpdf/invalid-id-xref.out +++ b/qpdf/qtest/qpdf/invalid-id-xref.out @@ -15,4 +15,6 @@ modify annotations: allowed modify other: not allowed modify anything: not allowed File is not linearized +WARNING: invalid-id-xref.pdf, trailer at offset 910 -> dictionary key /ID: operation for array attempted on object of type null: returning null +WARNING: invalid-id-xref.pdf, trailer at offset 910 -> dictionary key /ID -> null returned from invalid array access: operation for string attempted on object of type null: returning empty string qpdf: operation succeeded with warnings diff --git a/qpdf/qtest/qpdf/job-json-input-file-password.pdf b/qpdf/qtest/qpdf/job-json-input-file-password.pdf index dc56bf36..a54e6e4e 100644 Binary files a/qpdf/qtest/qpdf/job-json-input-file-password.pdf and b/qpdf/qtest/qpdf/job-json-input-file-password.pdf differ