2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-06-01 01:40:51 +00:00
Commit Graph

428 Commits

Author SHA1 Message Date
Jay Berkenbilt
750aca5b94 First increment of improving handling of weak crypto (fixes #358) 2021-11-11 12:24:15 -05:00
Jay Berkenbilt
f45dacf4cb Make recovery logic flexible about where objects end (fixes #573)
Don't assume endobj is at the beginning of the line. This means we are
looking at tokens for every line, but the odds of n n obj appearing in
the middle of the object are likely much lower than endobj not being
at the beginning of the line or missing entirely. This will probably
have a negative impact on recovery time for very large files.
Hopefully it will be worth it.
2021-11-07 15:27:22 -05:00
Jay Berkenbilt
4a648b9a00 Fix bug in merging resources /DR from foreign AcroForm (fixes #548)
When making resources indirect in from_dr, the code was using the
wrong owning QPDF, forgetting that from_dr had already been copied
using CopyForeignObject.
2021-11-04 12:29:42 -04:00
Jay Berkenbilt
9b28933647 Check object ownership when adding
When adding a QPDFObjectHandle to an array or dictionary, if possible,
check if the new object belongs to the same QPDF. This makes it much
easier to find incorrect code than waiting for the situation to be
detected when the file is written.
2021-11-04 12:29:42 -04:00
Jay Berkenbilt
73752683c9 Fix overlay/underlay on page with no resources (fixes #527) 2021-11-03 16:00:05 -04:00
Jay Berkenbilt
532a4f3d60 Detect recoverable but invalid zlib data streams (fixes #562) 2021-11-03 09:43:17 -04:00
Jay Berkenbilt
7ed991343b Better diagnostics when --pages is not closed (fixes #555) 2021-11-02 16:22:37 -04:00
Fredrik Fornwall
e0775238b8 Fix QPDFEFStreamObjectHelper::{get,set}Subtype
The /Subtype entry that specifies the mime type of an embedded file is
inside the embedded file stream dictionary directly, not it in the
parameter dictionary.

See Table 45 and 46 in the PDF 1.7 specification:
https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf#page=112
2021-09-10 10:02:24 -04:00
Jay Berkenbilt
df38fe8e48 Fix string bounds checking in completion code (fixes #441) 2021-05-13 13:06:58 -04:00
Jay Berkenbilt
30ac51bc78 Exclude unreferenced objects in object streams (fixes #520) 2021-05-08 09:42:09 -04:00
Jay Berkenbilt
8971443e46 QPDF::addPage*: handle duplicate pages more robustly 2021-04-05 10:58:10 -04:00
Jay Berkenbilt
ec48820c3c Fix loop detection in NNTree 2021-04-05 07:59:02 -04:00
Jay Berkenbilt
85884c363c Allow /DR to be direct in /AcroForm
Also handle direct annotation, though this is much less likely.
2021-03-11 11:43:38 -05:00
Jay Berkenbilt
addc0672d1 Tweak form copying to avoid gratuitous field renames
When copying a page from the original file to the output in --pages,
don't alter the fields or annotations for the first copy of each page.
2021-03-05 05:31:15 -05:00
Jay Berkenbilt
cb6e53136f QPDFAcroFormDocumentHelper: add missing analyze calls 2021-03-04 18:11:44 -05:00
Jay Berkenbilt
f68e25c7f2 Don't use handleWarning, which is being reverted 2021-03-04 15:59:45 -05:00
Jay Berkenbilt
9fb174b9e9 Major rework of handling form fields when copying pages (fixes #509) 2021-03-04 15:08:37 -05:00
Jay Berkenbilt
887f35efaa When resolving font from /DR, copy it into resources 2021-03-04 15:08:36 -05:00
Jay Berkenbilt
d7ffdfa994 Add optional conflict detection to mergeResources
Also improve behavior around direct vs. indirect resources.
2021-03-04 15:08:36 -05:00
Jay Berkenbilt
e17585c2d2 Remove unreferenced: ignore names that are not Fonts or XObjects
Converted ResourceFinder to ParserCallbacks so we can better detect
the name that precedes various operators and use the operators to sort
the names into resource types. This enables us to be smarter about
detecting unreferenced resources in pages and also sets the stage for
reconciling differences in /DR across documents.
2021-03-03 17:05:49 -05:00
Jay Berkenbilt
fa2516df71 Fix behavior for finding /Q, /DA, and /DR for form fields
If not found in the field hierarchy, /Q and /DA are supposed to be
looked up in the document-level form dictionary. /DR is supposed to
only come from the document dictionary.
2021-03-03 17:05:19 -05:00
Jay Berkenbilt
a4d6589ff2 Have QPDFObjectHandle notice when replaceObject was called
This results in a performance penalty of 1% to 2% when replaceObject
and swapObjects are never called and a somewhat larger penalty if they
are called, but it's worth it to avoid very confusing behavior as
discussed in depth in qpdf#507.
2021-02-25 07:32:46 -05:00
Jay Berkenbilt
1886673d7e Spell check 2021-02-23 10:38:05 -05:00
Jay Berkenbilt
9e00be7ffa Remove warning that gives false positives in some normal cases 2021-02-23 08:26:21 -05:00
Jay Berkenbilt
039eb4a253 Fix input file = output file test for split pages 2021-02-23 08:26:21 -05:00
Jay Berkenbilt
be3a8c0e7a Keep only referenced form fields in --pages 2021-02-23 08:26:21 -05:00
Jay Berkenbilt
50037fb33d Fix test case to not leave stray files behind 2021-02-22 19:51:36 -05:00
Jay Berkenbilt
83216e640c Preserve form fields when splitting pages (fixes #340) 2021-02-22 18:42:06 -05:00
Jay Berkenbilt
61d41e2e88 Add copyAnnotations, use with overlay/underlay (fixes #395) 2021-02-22 18:42:06 -05:00
Jay Berkenbilt
a9ae8cadc6 Add transformAnnotations and fix flattenRotations to use it 2021-02-21 17:13:09 -05:00
Jay Berkenbilt
7540d2082a Explicitly override inherited rotate in flattenRotations 2021-02-21 14:58:45 -05:00
Jay Berkenbilt
92fbc6fdf5 QPDFObjectHandle::copyStream 2021-02-21 06:36:30 -05:00
Jay Berkenbilt
35dd11f356 Allow --rotate=0 2021-02-20 16:29:34 -05:00
Jay Berkenbilt
0a52e60ece Use QUtil::path_basename 2021-02-18 09:59:03 -05:00
Jay Berkenbilt
dfce581754 Add numeric argument to --collate
This takes pages from the file in groups of n with default = 1. This
partially fixes the enhancement in issue #505 but doesn't implement
the entire suggestion.
2021-02-17 20:07:45 -05:00
Jay Berkenbilt
efbb21673c Add functional versions of QPDFObjectHandle::replaceStreamData
Also fix a bug in checking consistency of length for stream data
providers. Length should not be checked or recorded if the provider
says it failed to generate the data.
2021-02-14 14:42:24 -05:00
Jay Berkenbilt
07f40bd254 QUtil::double_to_string: trim trailing zeroes with option to disable 2021-02-13 02:30:00 -05:00
Jay Berkenbilt
accb891b4f Add attachment information to the json output 2021-02-10 15:46:18 -05:00
Jay Berkenbilt
832d792e4e Add CLI support for working with attachments 2021-02-10 10:03:27 -05:00
Jay Berkenbilt
ad34b9c278 Implement helpers for file attachments 2021-02-10 06:57:37 -05:00
Jay Berkenbilt
e076c9bf08 Remove erroneous handling of /EFF for stream decryption
I thought /EFF was supposed to be used as a default for decrypting
embedded file streams, but actually it's supposed to be advice to a
conforming writer about handling new ones. This makes sense since the
findAttachmentStreams code, which is not actually needed, was never
right.
2021-02-06 17:08:41 -05:00
Jay Berkenbilt
ac2b3b96e1 Make wrong object stream type a warning 2021-02-06 14:29:11 -05:00
Jay Berkenbilt
3de67173de Better fix to insecure password check (fixes #501) 2021-02-04 20:44:05 -05:00
Jay Berkenbilt
63158cf546 Add --password-file=filename option (fixes #499) 2021-02-04 16:48:53 -05:00
Jay Berkenbilt
21b0f4acfc Require --allow-insecure to create certain encrypted files (fixes #501)
For now, --allow-insecure allows creation of files with the owner
passwords empty or matching the user password.
2021-02-04 15:57:13 -05:00
Jay Berkenbilt
faa2e3ddfd Handle older PDFs whose form XObjects inherit resources (fixes #494)
When removing unreferenced resources, notice if a page (recursively)
contains a form XObject with unreferenced resources, and count any
such resources as referenced by the page.
2021-02-02 18:06:05 -05:00
Jay Berkenbilt
e7e20772ed name/number trees: remove 2021-01-26 09:12:23 -05:00
Jay Berkenbilt
5816fb44b8 name/number trees: insertAfter 2021-01-25 15:39:10 -05:00
Jay Berkenbilt
b5614f611d Implement repair and insert for name/number trees 2021-01-24 19:31:45 -05:00
Jay Berkenbilt
04edfe9fad QPDFObjectHandle::newUnicodeString to uses UTF-16 only when needed
Use the first of ASCII, PDFDocEncoding, or UTF-16 that is capable of
encoding the string.
2021-01-24 03:27:28 -05:00