mirror of
https://github.com/qpdf/qpdf.git
synced 2025-03-29 12:52:24 +00:00
Use inline image token in content parser
This commit is contained in:
parent
ba453ba4ff
commit
55ee55394c
@ -907,42 +907,31 @@ QPDFObjectHandle::parseContentStream_internal(PointerHolder<Buffer> stream_data,
|
|||||||
// terminated the token. Read until end of inline image.
|
// terminated the token. Read until end of inline image.
|
||||||
char ch;
|
char ch;
|
||||||
input->read(&ch, 1);
|
input->read(&ch, 1);
|
||||||
char buf[4];
|
tokenizer.expectInlineImage();
|
||||||
memset(buf, '\0', sizeof(buf));
|
QPDFTokenizer::Token t = tokenizer.readToken(input, description, true);
|
||||||
bool done = false;
|
if (t.getType() == QPDFTokenizer::tt_bad)
|
||||||
std::string inline_image;
|
|
||||||
while (! done)
|
|
||||||
{
|
{
|
||||||
if (input->read(&ch, 1) == 0)
|
QTC::TC("qpdf", "QPDFObjectHandle EOF in inline image");
|
||||||
|
throw QPDFExc(qpdf_e_damaged_pdf, input->getName(),
|
||||||
|
"stream data", input->tell(),
|
||||||
|
"EOF found while reading inline image");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Skip back over EI
|
||||||
|
input->seek(-3, SEEK_CUR);
|
||||||
|
std::string inline_image = t.getRawValue();
|
||||||
|
for (int i = 0; i < 4; ++i)
|
||||||
{
|
{
|
||||||
QTC::TC("qpdf", "QPDFObjectHandle EOF in inline image");
|
if (inline_image.length() > 0)
|
||||||
throw QPDFExc(qpdf_e_damaged_pdf, input->getName(),
|
|
||||||
"stream data", input->tell(),
|
|
||||||
"EOF found while reading inline image");
|
|
||||||
}
|
|
||||||
inline_image += ch;
|
|
||||||
memmove(buf, buf + 1, sizeof(buf) - 1);
|
|
||||||
buf[sizeof(buf) - 1] = ch;
|
|
||||||
if (strchr(" \t\n\v\f\r", buf[0]) &&
|
|
||||||
(buf[1] == 'E') &&
|
|
||||||
(buf[2] == 'I') &&
|
|
||||||
strchr(" \t\n\v\f\r", buf[3]))
|
|
||||||
{
|
|
||||||
// We've found an EI operator.
|
|
||||||
done = true;
|
|
||||||
input->seek(-3, SEEK_CUR);
|
|
||||||
for (int i = 0; i < 4; ++i)
|
|
||||||
{
|
{
|
||||||
if (inline_image.length() > 0)
|
inline_image.erase(inline_image.length() - 1);
|
||||||
{
|
|
||||||
inline_image.erase(inline_image.length() - 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
QTC::TC("qpdf", "QPDFObjectHandle inline image token");
|
||||||
|
callbacks->handleObject(
|
||||||
|
QPDFObjectHandle::newInlineImage(inline_image));
|
||||||
}
|
}
|
||||||
QTC::TC("qpdf", "QPDFObjectHandle inline image token");
|
|
||||||
callbacks->handleObject(
|
|
||||||
QPDFObjectHandle::newInlineImage(inline_image));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user