mirror of
https://github.com/qpdf/qpdf.git
synced 2025-01-03 07:12:28 +00:00
Bug fix: getStreamData should on unfilterable stream (fixes #425)
This commit is contained in:
parent
22f7f459e6
commit
4977a7efa5
@ -1,3 +1,10 @@
|
|||||||
|
2020-04-08 Jay Berkenbilt <ejb@ql.org>
|
||||||
|
|
||||||
|
* Bug fix: qpdf 10.0.0 introduced a bug in which
|
||||||
|
QPDFObjectHandle::getStreamData would return the raw data when
|
||||||
|
called on an unfilterable stream instead of throwing an exception
|
||||||
|
like it's supposed to. Fixes #425.
|
||||||
|
|
||||||
2020-04-07 Jay Berkenbilt <ejb@ql.org>
|
2020-04-07 Jay Berkenbilt <ejb@ql.org>
|
||||||
|
|
||||||
* Improve pdf-invert-images example to show a pattern of copying
|
* Improve pdf-invert-images example to show a pattern of copying
|
||||||
|
@ -163,7 +163,9 @@ PointerHolder<Buffer>
|
|||||||
QPDF_Stream::getStreamData(qpdf_stream_decode_level_e decode_level)
|
QPDF_Stream::getStreamData(qpdf_stream_decode_level_e decode_level)
|
||||||
{
|
{
|
||||||
Pl_Buffer buf("stream data buffer");
|
Pl_Buffer buf("stream data buffer");
|
||||||
if (! pipeStreamData(&buf, nullptr, 0, decode_level, false, false))
|
bool filtered;
|
||||||
|
pipeStreamData(&buf, &filtered, 0, decode_level, false, false);
|
||||||
|
if (! filtered)
|
||||||
{
|
{
|
||||||
throw QPDFExc(qpdf_e_unsupported, qpdf->getFilename(),
|
throw QPDFExc(qpdf_e_unsupported, qpdf->getFilename(),
|
||||||
"", this->offset,
|
"", this->offset,
|
||||||
|
@ -954,12 +954,16 @@ foreach (my $i = 1; $i <= 3; ++$i)
|
|||||||
show_ntests();
|
show_ntests();
|
||||||
# ----------
|
# ----------
|
||||||
$td->notify("--- Stream data ---");
|
$td->notify("--- Stream data ---");
|
||||||
$n_tests += 1;
|
$n_tests += 2;
|
||||||
|
|
||||||
$td->runtest("get stream data",
|
$td->runtest("get stream data",
|
||||||
{$td->COMMAND => "test_driver 11 stream-data.pdf"},
|
{$td->COMMAND => "test_driver 11 stream-data.pdf"},
|
||||||
{$td->FILE => "test11.out", $td->EXIT_STATUS => 0},
|
{$td->FILE => "test11.out", $td->EXIT_STATUS => 0},
|
||||||
$td->NORMALIZE_NEWLINES);
|
$td->NORMALIZE_NEWLINES);
|
||||||
|
$td->runtest("get stream data fails on jpeg",
|
||||||
|
{$td->COMMAND => "test_driver 68 jpeg-qstream.pdf"},
|
||||||
|
{$td->FILE => "test68.out", $td->EXIT_STATUS => 0},
|
||||||
|
$td->NORMALIZE_NEWLINES);
|
||||||
|
|
||||||
show_ntests();
|
show_ntests();
|
||||||
# ----------
|
# ----------
|
||||||
|
BIN
qpdf/qtest/qpdf/jpeg-qstream.pdf
Normal file
BIN
qpdf/qtest/qpdf/jpeg-qstream.pdf
Normal file
Binary file not shown.
4
qpdf/qtest/qpdf/test68.out
Normal file
4
qpdf/qtest/qpdf/test68.out
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
get unfilterable stream: jpeg-qstream.pdf (offset 284): getStreamData called on unfilterable stream
|
||||||
|
filtered stream data okay
|
||||||
|
raw stream data okay
|
||||||
|
test 68 done
|
@ -2168,6 +2168,35 @@ void runtest(int n, char const* filename1, char const* arg2)
|
|||||||
w.setStaticID(true);
|
w.setStaticID(true);
|
||||||
w.write();
|
w.write();
|
||||||
}
|
}
|
||||||
|
else if (n == 68)
|
||||||
|
{
|
||||||
|
QPDFObjectHandle root = pdf.getRoot();
|
||||||
|
QPDFObjectHandle qstream = root.getKey("/QStream");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
qstream.getStreamData();
|
||||||
|
std::cout << "oops -- didn't throw" << std::endl;
|
||||||
|
}
|
||||||
|
catch (std::exception& e)
|
||||||
|
{
|
||||||
|
std::cout << "get unfilterable stream: " << e.what()
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
PointerHolder<Buffer> b1 = qstream.getStreamData(qpdf_dl_all);
|
||||||
|
if ((b1->getSize() > 10) &&
|
||||||
|
(memcmp(b1->getBuffer(),
|
||||||
|
"wwwwwwwww", 9) == 0))
|
||||||
|
{
|
||||||
|
std::cout << "filtered stream data okay" << std::endl;
|
||||||
|
}
|
||||||
|
PointerHolder<Buffer> b2 = qstream.getRawStreamData();
|
||||||
|
if ((b2->getSize() > 10) &&
|
||||||
|
(memcmp(b2->getBuffer(),
|
||||||
|
"\xff\xd8\xff\xe0\x00\x10\x4a\x46\x49\x46", 10) == 0))
|
||||||
|
{
|
||||||
|
std::cout << "raw stream data okay" << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw std::runtime_error(std::string("invalid test ") +
|
throw std::runtime_error(std::string("invalid test ") +
|
||||||
|
Loading…
Reference in New Issue
Block a user