2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-09-29 05:29:06 +00:00
Commit Graph

286 Commits

Author SHA1 Message Date
Jay Berkenbilt
4eccb9d87b Add random number functions to QUtil 2012-12-31 10:32:32 -05:00
Jay Berkenbilt
16a23368e7 Fix infinite loop trimming passwords with ( in them 2012-12-31 10:32:31 -05:00
Jay Berkenbilt
0873e42300 SHA2 pipeline with support for 256, 384, and 512 bits
Implemented pipeline around sph sha calls using standard test vectors
for full-byte values.  Did not test or support partial byte values.
2012-12-31 05:36:51 -05:00
Jay Berkenbilt
c9da66a018 Incorporate sha2 code from sphlib 3.0
Changes from upstream are limited to change #include paths so that I
can place header files and included "c" files in a subdirectory.  I
didn't keep the unit tests from sphlib but instead verified them by
running them manually.  I will implement the same tests using the
Pl_SHA2 pipeline except that sphlib's sha2 implementation supports
partial bytes, which I will not exercise in qpdf or our tests.
2012-12-31 05:36:51 -05:00
Jay Berkenbilt
3680922ae5 Allow specification of AES initialization vector 2012-12-31 05:36:50 -05:00
Jay Berkenbilt
9b42f526df Update AES classes to work with 256-bit keys 2012-12-31 05:36:50 -05:00
Jay Berkenbilt
774584163f Add ExtensionLevel support to version handling
All version operations are now fully aware of extension levels.
2012-12-31 05:36:50 -05:00
Jay Berkenbilt
3101955ac0 Add V5 parameters to EncryptionData 2012-12-31 05:36:50 -05:00
Jay Berkenbilt
68447bb556 change EncryptionData 2012-12-31 05:36:50 -05:00
Jay Berkenbilt
04c203ae06 Eliminate flattenScalarReferences 2012-12-31 05:36:48 -05:00
Jay Berkenbilt
b4e7d6ed32 Improve memory safety of finding PDF header 2012-12-25 15:13:44 -05:00
Jay Berkenbilt
7f84239cad Find PDF header anywhere in the first 1024 bytes 2012-12-25 14:43:37 -05:00
Jay Berkenbilt
f256670eba Ignore objects with offset 0 2012-11-20 13:57:37 -05:00
Jay Berkenbilt
041397fdab Allow reading from InputSource and writing to Pipeline
Allowing users to subclass InputSource and Pipeline to read and write
from/to arbitrary sources provides the maximum flexibility for users
who want to read and write from other than files or memory.
2012-09-23 17:42:26 -04:00
Jay Berkenbilt
8c99e4a6c0 Indicate pre-release version 2012-09-23 17:41:08 -04:00
Jay Berkenbilt
b4dc0f072a Prepare 3.0.2 release 2012-09-06 15:47:58 -04:00
Jay Berkenbilt
7e4a079674 Update libtool data for API changes 2012-09-06 15:31:35 -04:00
Jay Berkenbilt
c1627d0438 Add QPDFWriter::setExtraHeaderText 2012-09-06 15:31:12 -04:00
Jay Berkenbilt
fc4c82a950 Reset state in QPDF::calculateLinearizationData
This makes it possible to use two different writers to write
linearized files from the same QPDF object.
2012-09-06 15:28:16 -04:00
Jay Berkenbilt
8d2b29ef98 Fix segmentation fault with use of QPDFWriter::setOutputMemory 2012-09-06 14:39:06 -04:00
Jay Berkenbilt
59432b5c70 Prepare 3.0.1 release 2012-08-11 13:41:18 -04:00
Jay Berkenbilt
29e9c34fe3 Bug fix: let EOF resolve literal token
Previously only whitespace and comments did it.  This fix is needed
for object streams whose last object is a literal (name, integer,
real, string) not terminated by space or newline.
2012-08-11 09:29:04 -04:00
Jay Berkenbilt
137dc7acb9 Refactor: move resolution of literal to its own method 2012-08-11 09:22:59 -04:00
Jay Berkenbilt
511e68758c Update version to 3.0.0 2012-08-02 06:52:33 -04:00
Jay Berkenbilt
32051283b9 Fix spelling errors 2012-07-29 14:44:12 -04:00
Jay Berkenbilt
2280c4f6d1 Update documentation and version numbers
3.0.rc1
2012-07-28 22:03:36 -04:00
Tobias Hoffmann
9c00874e77 added QPDFObjectHandle::replaceStreamData(std::string data). 2012-07-25 03:02:46 +02:00
Jay Berkenbilt
316328704b Windows compilation fixes 2012-07-21 20:51:56 -04:00
Jay Berkenbilt
6bbea4baa0 Implement QPDFObjectHandle::parse
Move object parsing code from QPDF to QPDFObjectHandle and
parameterize the parts of it that are specific to a QPDF object.
Provide a version that can't handle indirect objects and that can be
called on an arbitrary string.

A side effect of this change is that the offset used when reporting
invalid stream length has changed, but since the new value seems like
a better value than the old one, the test suite has been updated
rather than making the code backward compatible.  This only effects
the offset reported for invalid streams that lack /Length or have an
invalid /Length key.

Updated some test code and exmaples to use QPDFObjectHandle::parse.

Supporting changes include adding a BufferInputSource constructor that
takes a string.
2012-07-21 09:06:10 -04:00
Jay Berkenbilt
f3e267fce2 Move readToken from QPDF to QPDFTokenizer 2012-07-21 09:06:10 -04:00
Jay Berkenbilt
15eaed5c52 Refactor: pull *InputSource out of QPDF
InputSource, FileInputSource, and BufferInputSource are now top-level
classes instead of privately nested inside QPDF.
2012-07-21 09:06:06 -04:00
Jay Berkenbilt
8657c6f004 Prevent seeking before beginning of BufferInputSource 2012-07-18 09:50:05 -04:00
Jay Berkenbilt
a101533e0a Add command line option to copy encryption from other file
Add --copy-encryption and --encryption-file-password options to qpdf.
Also strengthen test suite for copying encryption.  The strengthened
test suite would have caught the failure to preserve AES and the
failure to update the file version, which was invalidating the
encrypted data.
2012-07-15 21:15:24 -04:00
Jay Berkenbilt
b26ce88ea1 Minor fixes to copyEncryptionParameters
This fixes were to code added yesterday; the problems would not have
impacted any previously released code.  These are all changes related
to the possibility that copyEncryptionParameters may be called on
behalf a different QPDF than the one being written.
2012-07-15 21:14:02 -04:00
Jay Berkenbilt
db95960ac1 Bug fix: preserve AES when copying encryption parameters 2012-07-15 19:07:59 -04:00
Jay Berkenbilt
b501251291 qpdf: push inherited attributes to page when showing images
from qpdf command-line tool
2012-07-15 16:22:28 -04:00
Jay Berkenbilt
0575d77d77 Add public QPDFWriter::copyEncryptionParameters
Method to copy encryption parameters from another file.  Adapted from
existing code to copy encryption parameters from the original file.
2012-07-14 09:14:41 -04:00
Jay Berkenbilt
1c944e4c89 Have QPDFWriter detect foreign objects while writing
Throw an exception that directs the user to QPDF::copyForeignObject.
2012-07-14 08:07:23 -04:00
Jay Berkenbilt
e7b8f297ba Support copying objects from another QPDF object
This includes QPDF::copyForeignObject and supporting foreign objects
as arguments to addPage*.
2012-07-11 15:54:33 -04:00
Jay Berkenbilt
8a217eb3a2 Add concept of reserved objects
QPDFObjectHandle::{new,is,assert}Reserved, QPDF::replaceReserved
provide a mechanism to add objects to a PDF file when there are
circular references.  This is a prerequisite to copying objects from
one PDF to another.
2012-07-10 23:34:32 -04:00
Jay Berkenbilt
1dc25c0217 Fix: make unparse virtual for Null and Real 2012-07-08 16:01:12 -04:00
Tobias Hoffmann
8720446b23 Added assertNumber and assertScalar to QPDFObjectHandle 2012-07-07 18:55:08 -04:00
Tobias Hoffmann
a8266ccb0e Added public assert{Type} methods to QPDFObjectHandle 2012-07-07 18:53:38 -04:00
Tobias Hoffmann
39bbaa86e3 Build this->all_pages while traversing with pushInheritedAttributesToPage 2012-07-07 17:45:10 -04:00
Jay Berkenbilt
e2dedde4bd Don't require stream data provider to know length in advance
Breaking API change: length parameter has disappeared from the
StreamDataProvider version of QPDFObjectHandle::replaceStreamData
since it is no longer necessary to compute it in advance.  This
breaking change is justified by the fact that removing the length
parameter provides the caller an opportunity to simplify the calling
code.
2012-07-07 17:33:45 -04:00
Jay Berkenbilt
8705e2e8fc Add QPDFWriter method to output to FILE* 2012-07-05 21:24:04 -04:00
Tobias Hoffmann
abb53ac369 Limited inheritance to the attributes explicitly listed in the PDF spec
Previous versions of qpdf incorrectly passed arbitrary objects from
/Pages objects down to individual pages in direct contradition with
the PDF specification.  These are now left in /Pages.  When
intermediate /Pages nodes are being discarded as when the /Pages tree
is being flattened, a warning is issued when unknown keys are
encountered.
2012-07-04 23:04:55 -04:00
Tobias Hoffmann
7770a1b036 Added public method QPDF::pushInheritedAttributesToPage
Refactored optimizePagesTree to pushInheritedAttributesToPage and made
public
2012-07-04 16:24:03 -04:00
Jay Berkenbilt
5f59c32f87 Add a few minor enhancements to recent work
Test coverage case for new newStream method
Expose decimal_places argument for double-based newReal

All enhancements suggested by Tobias.
2012-06-27 10:43:27 -04:00
Tobias Hoffmann
f07e3370f0 Add Pl_Concatenate filter 2012-06-27 10:20:38 -04:00
Tobias Hoffmann
43c404b45a Add QPDFObjectHandle::newStream(QPDF *, std::string const&)
This makes the code simpler than having to create a buffer of a fixed
size and copy the string to it.
2012-06-27 10:19:57 -04:00
Tobias Hoffmann
75054c0b94 Add QPDFObjectHandle::newReal(double) 2012-06-27 10:19:01 -04:00
Jay Berkenbilt
2266c6232b Rework InputSource::readLine to make it much more efficient
This rework makes xref reconstruction run much faster and use much
less memory.
2012-06-27 06:48:06 -04:00
Jay Berkenbilt
736bafbb9c Rename seek functions in QUtil 2012-06-26 23:10:10 -04:00
Jay Berkenbilt
0802ba275f Visual C++ and mingw32 fixes for large files 2012-06-26 23:05:59 -04:00
Jay Berkenbilt
5e3167e856 Set version to 3.0.a0 2012-06-25 21:35:30 -04:00
Jay Berkenbilt
1a3e88ca09 Fix large file support for 32-bit Linux 2012-06-25 10:51:44 -04:00
Jay Berkenbilt
c16db4106c Increase padding in linearized files
With QPDF allowing integers to contain 64-bit quantities, this change
is necessary to be able to linearize files whose sizes might be larger
than 10 digits.
2012-06-24 15:56:59 -04:00
Jay Berkenbilt
8318d81ada Fix and test support for files >= 4 GB 2012-06-24 15:56:50 -04:00
Jay Berkenbilt
781c313058 Change QPDF_Integer from int to long long
This makes it possible to store offsets that are larger than 2 GB in
the trailer dictionary.
2012-06-24 15:20:01 -04:00
Jay Berkenbilt
4f305488d8 Improve the FILE* version of QPDF::processFile 2012-06-23 18:23:06 -04:00
Tobias Hoffmann
7f95ad5b92 Fixed missing throw 2012-06-23 18:17:01 -04:00
Jay Berkenbilt
bf059a6001 Replace the 8-bit characters with \x.. in QPDFWriter.cc
This just makes it safer to pull up this file in an editor.
2012-06-23 09:05:06 -04:00
Jay Berkenbilt
6c0af0844c Switch some code to use empty newArray/newDictionary 2012-06-22 10:09:42 -04:00
Jay Berkenbilt
b6bdc0f595 Add factory methods for creating empty arrays and dictionaries.
Also updated pdf_from_scratch test driver to use the new factories,
and made some cosmetic improvements and documentation updates for the
emptyPDF() method.
2012-06-22 09:46:33 -04:00
Jay Berkenbilt
a0768e4190 Add QPDF::emptyPDF() and pdf_from_scratch test code 2012-06-21 23:09:05 -04:00
Jay Berkenbilt
81e8752362 Use qpdf_offset_t in place of off_t in public APIs.
off_t is used internally only when needed to talk to standard
libraries.  This requires that the "long long" type be supported by
the compiler.
2012-06-21 21:23:24 -04:00
Jay Berkenbilt
d1ebe30ff6 Add QPDFObjectHandle::shallowCopy() 2012-06-21 16:15:09 -04:00
Jay Berkenbilt
9689f4cdcf Use getRoot() instead of looking it up in the trailer 2012-06-21 16:15:09 -04:00
Jay Berkenbilt
11d33a45fa Iterate of /Info's keys, not trailer's keys, to seed /ID
Thanks Tobias Hoffmann for noticing the error.
2012-06-21 15:52:53 -04:00
Jay Berkenbilt
3844aedd93 Add testing for page APIs 2012-06-21 15:01:02 -04:00
Jay Berkenbilt
eb802cfa8c Implement page manipulation APIs 2012-06-21 15:01:02 -04:00
Jay Berkenbilt
e01ae1968b Split page handling APIs into a separate source file 2012-06-21 15:01:02 -04:00
Jay Berkenbilt
df493c352f Refactor optimizePagesTree
Split optimizePagesTree into a simpler top-level routine and a
recursive internal routine.
2012-06-21 15:01:02 -04:00
Tobias Hoffmann
5d3f93be29 Added first version of pages API. 2012-06-21 15:01:02 -04:00
Tobias Hoffmann
47a846a7e0 Added method to clear pages cache. 2012-06-21 15:01:02 -04:00
Jay Berkenbilt
3b413ca87c Fix typo in comment 2012-06-21 15:00:58 -04:00
Jay Berkenbilt
f59ff6fcc2 fix include order for off_t 2012-06-21 14:11:22 -04:00
Jay Berkenbilt
fbe68d63f0 fix doc comment 2012-06-21 10:59:33 -04:00
Jay Berkenbilt
bc1c4bb578 Add QPDF::processFile that takes an open FILE* 2012-06-21 08:00:35 -04:00
Tobias Hoffmann
db7474e0fa Added additional array mutators
Added methods to append to arrays, insert items into arrays, and
replace array contents with a vector of items.
2012-06-20 15:29:44 -04:00
Jay Berkenbilt
b2e6818935 Fix wording error in error message 2012-06-20 15:29:42 -04:00
Jay Berkenbilt
5d4cad9c02 ABI change: fix use of off_t, size_t, and integer types
Significantly improve the code's use of off_t for file offsets, size_t
for memory sizes, and integer types in cases where there has to be
compatibility with external interfaces.  Rework sections of the code
that would have prevented qpdf from working on files larger than 2 (or
maybe 4) GB in size.
2012-06-20 15:20:26 -04:00
Jay Berkenbilt
24e2b2b76f Fix gcc 4.7 warnings about C++11 2012-06-20 15:18:14 -04:00
Jay Berkenbilt
92c94e7df2 Add symbol versioning
For ELF systems, turn on versioned symbols by default, and add a
configure option to enable or disable them.
2012-06-20 15:18:12 -04:00
Jay Berkenbilt
01bcda8974 fix PCRE calls to remove use of deprecated API
pcre_info -> pcre_fullinfo.  Closes issue 3489349.  Thanks Tim Harder.
2012-04-06 21:47:46 -04:00
Jay Berkenbilt
8e9fe21316 Update for 2.3.1 2011-12-28 17:19:40 -05:00
Jay Berkenbilt
92f0207de8 fix MSVC 2010 issues 2011-12-28 16:40:33 -05:00
Jay Berkenbilt
11314a9551 Don't declare any PCRE objects static. 2011-12-28 14:32:33 -05:00
Jay Berkenbilt
1d1d21d3fe ready for 2.3.0 release 2011-08-11 15:34:41 -04:00
Jay Berkenbilt
788f6f7769 fix small logic error surrounding adding newlines; in practice, the logic error would probably never manifest itself without other code changes 2011-08-11 15:22:59 -04:00
Jay Berkenbilt
0abdf5381c fix memory error caught by valgrind 2011-08-11 14:11:27 -04:00
Jay Berkenbilt
76b1659177 enhance PointerHolder so that it can explicitly be told to use delete [] instead of delete, thus making it useful to run valgrind over qpdf during its test suite 2011-08-11 11:57:37 -04:00
Jay Berkenbilt
14fe2e6de3 qpdf_set_info_key, qpdf_get_info_key 2011-08-11 10:48:37 -04:00
Jay Berkenbilt
ce358f103e remove stray XXX comment 2011-08-11 10:17:24 -04:00
Jay Berkenbilt
9a1fad4077 comments 2011-08-10 20:57:52 -04:00
Jay Berkenbilt
a42a4068b5 preserve /EncryptMetadata when copying encryption parameters 2011-08-10 19:47:18 -04:00
Jay Berkenbilt
da39d2b1b1 2.3.a1 2011-08-10 16:48:00 -04:00
Jay Berkenbilt
759c56e1fe implement ability to save PDF to memory, also update ChangeLog 2011-08-10 16:34:29 -04:00
Jay Berkenbilt
655c55f848 implement methods to get dictionary and array contents as map and vector 2011-08-10 13:33:58 -04:00