diff options
author | Jay Berkenbilt <ejb@ql.org> | 2019-01-31 21:51:52 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2019-02-01 02:28:44 +0100 |
commit | eb49e07c0afc1b30b53d3ae2849c824c9407f00d (patch) | |
tree | e7c73b1115fcd5b7ea3c62376cb10e680724fb1c /libqpdf/QPDFPageObjectHelper.cc | |
parent | 5211bcb5eaa2b6b3c8aa48580f1b97314c37bb4a (diff) | |
download | qpdf-eb49e07c0afc1b30b53d3ae2849c824c9407f00d.tar.zst |
Make inline image token exactly contain the image data
Do not include the trailing EI, and handle cases where EI is not
preceded by a delimiter. Such cases have been seen in the wild.
Diffstat (limited to 'libqpdf/QPDFPageObjectHelper.cc')
-rw-r--r-- | libqpdf/QPDFPageObjectHelper.cc | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/libqpdf/QPDFPageObjectHelper.cc b/libqpdf/QPDFPageObjectHelper.cc index caaff853..e72b4c70 100644 --- a/libqpdf/QPDFPageObjectHelper.cc +++ b/libqpdf/QPDFPageObjectHelper.cc @@ -228,10 +228,6 @@ InlineImageTracker::handleToken(QPDFTokenizer::Token const& token) { std::string image_data(token.getValue()); size_t len = image_data.length(); - // The token ends with delimiter followed by EI, so it - // will always be at least 3 bytes long. We want to - // exclude the EI and preceding delimiter. - len = (len >= 3 ? len - 3 : 0); if (len >= this->min_size) { QTC::TC("qpdf", "QPDFPageObjectHelper externalize inline image"); @@ -256,14 +252,18 @@ InlineImageTracker::handleToken(QPDFTokenizer::Token const& token) QTC::TC("qpdf", "QPDFPageObjectHelper keep inline image"); write(bi_str); writeToken(token); + state = st_top; } - state = st_top; } else if (token == QPDFTokenizer::Token(QPDFTokenizer::tt_word, "ID")) { bi_str += token.getValue(); dict_str += " >>"; } + else if (token == QPDFTokenizer::Token(QPDFTokenizer::tt_word, "EI")) + { + state = st_top; + } else { bi_str += token.getValue(); |