2
1
mirror of https://github.com/qpdf/qpdf.git synced 2025-02-12 00:28:31 +00:00

Change QPDFWriter stream_decode_level default to qpdf_dl_generalized

Also, fix disabling of preserve_encryption to be ignore
stream_decode_level, but disable preserve_encryption if compress_streams is
false.

Fixes #1286
This commit is contained in:
m-holger 2024-09-18 16:51:37 +01:00
parent ff0affd81d
commit 718b14008b
10 changed files with 21 additions and 6 deletions

View File

@ -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 <m.holger@qpdf.org>
* Bug fix: QPDFWriter stream DecodeLevel incorrectly defaulted to
none instead of generalied. Fixes #1286.
2024-08-25 M Holger <m.holger@qpdf.org>
* Add new command-line arguments --remove-metadata and --remove-info

View File

@ -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;

View File

@ -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};

View File

@ -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();

View File

@ -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"},

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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