mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-31 14:01:59 +00:00
replaceStreamData: accept uninitialized filter/decode_parms
These mean to leave the original values alone. This is needed for reconstructing streams from JSON given that the stream data and stream dictionary may appear in any order in the JSON.
This commit is contained in:
parent
56f1b411fe
commit
63c7eefe9d
@ -1,3 +1,9 @@
|
|||||||
|
2022-05-17 Jay Berkenbilt <ejb@ql.org>
|
||||||
|
|
||||||
|
* Allow passing *uninitialized* (not null) objects to
|
||||||
|
replaceStreamData as filter and/or decode_parms to leave any
|
||||||
|
existing values for /Filter and /DecodeParms untouched.
|
||||||
|
|
||||||
2022-05-15 Jay Berkenbilt <ejb@ql.org>
|
2022-05-15 Jay Berkenbilt <ejb@ql.org>
|
||||||
|
|
||||||
* Add QUtil::is_long_long to test whether a string can be
|
* Add QUtil::is_long_long to test whether a string can be
|
||||||
|
@ -1199,13 +1199,21 @@ class QPDFObjectHandle
|
|||||||
QPDF_DLL
|
QPDF_DLL
|
||||||
void replaceDict(QPDFObjectHandle const&);
|
void replaceDict(QPDFObjectHandle const&);
|
||||||
|
|
||||||
// Replace this stream's stream data with the given data buffer,
|
// REPLACING STREAM DATA
|
||||||
// and replace the /Filter and /DecodeParms keys in the stream
|
|
||||||
// dictionary with the given values. (If either value is empty,
|
// Note about all replaceStreamData methods: whatever values are
|
||||||
// the corresponding key is removed.) The stream's /Length key is
|
// passed as filter and decode_parms will overwrite /Filter and
|
||||||
// replaced with the length of the data buffer. The stream is
|
// /DecodeParms in the stream. Passing a null object
|
||||||
// interpreted as if the data read from the file, after any
|
// (QPDFObjectHandle::newNull()) will remove those values from the
|
||||||
// decryption filters have been applied, is as presented.
|
// stream dictionary. From qpdf 11, passing an *uninitialized*
|
||||||
|
// QPDFObjectHandle (QPDFObjectHandle()) will leave any existing
|
||||||
|
// values untouched.
|
||||||
|
|
||||||
|
// Replace this stream's stream data with the given data buffer.
|
||||||
|
// The stream's /Length key is replaced with the length of the
|
||||||
|
// data buffer. The stream is interpreted as if the data read from
|
||||||
|
// the file, after any decryption filters have been applied, is as
|
||||||
|
// presented.
|
||||||
QPDF_DLL
|
QPDF_DLL
|
||||||
void replaceStreamData(
|
void replaceStreamData(
|
||||||
std::shared_ptr<Buffer> data,
|
std::shared_ptr<Buffer> data,
|
||||||
|
@ -725,8 +725,12 @@ QPDF_Stream::replaceFilterData(
|
|||||||
QPDFObjectHandle const& decode_parms,
|
QPDFObjectHandle const& decode_parms,
|
||||||
size_t length)
|
size_t length)
|
||||||
{
|
{
|
||||||
this->stream_dict.replaceKey("/Filter", filter);
|
if (filter.isInitialized()) {
|
||||||
this->stream_dict.replaceKey("/DecodeParms", decode_parms);
|
this->stream_dict.replaceKey("/Filter", filter);
|
||||||
|
}
|
||||||
|
if (decode_parms.isInitialized()) {
|
||||||
|
this->stream_dict.replaceKey("/DecodeParms", decode_parms);
|
||||||
|
}
|
||||||
if (length == 0) {
|
if (length == 0) {
|
||||||
QTC::TC("qpdf", "QPDF_Stream unknown stream length");
|
QTC::TC("qpdf", "QPDF_Stream unknown stream length");
|
||||||
this->stream_dict.removeKey("/Length");
|
this->stream_dict.removeKey("/Length");
|
||||||
|
Loading…
Reference in New Issue
Block a user