Commit 12db09898e70fcdc308cf500a95fb166e696b6dc

Authored by Jay Berkenbilt
1 parent 701b518d

Don't interpret word tokens in content streams (fixes #82)

ChangeLog
1 1 2017-07-26 Jay Berkenbilt <ejb@ql.org>
2 2  
  3 + * Don't attempt to interpret syntactic keywords (like R and
  4 + endobj) found while parsing content streams.
  5 +
3 6 * Detect infinite loops while resolving objects. This could happen
4 7 if something inside an object that had to be resolved during
5 8 parsing, such as a stream length, recursively referenced the
... ...
libqpdf/QPDFObjectHandle.cc
... ... @@ -964,7 +964,11 @@ QPDFObjectHandle::parseInternal(PointerHolder&lt;InputSource&gt; input,
964 964 case QPDFTokenizer::tt_word:
965 965 {
966 966 std::string const& value = token.getValue();
967   - if ((value == "R") && (in_array || in_dictionary) &&
  967 + if (content_stream)
  968 + {
  969 + object = QPDFObjectHandle::newOperator(value);
  970 + }
  971 + else if ((value == "R") && (in_array || in_dictionary) &&
968 972 (olist.size() >= 2) &&
969 973 (! olist.at(olist.size() - 1).isIndirect()) &&
970 974 (olist.at(olist.size() - 1).isInteger()) &&
... ... @@ -996,10 +1000,6 @@ QPDFObjectHandle::parseInternal(PointerHolder&lt;InputSource&gt; input,
996 1000 input->seek(input->getLastOffset(), SEEK_SET);
997 1001 empty = true;
998 1002 }
999   - else if (content_stream)
1000   - {
1001   - object = QPDFObjectHandle::newOperator(token.getValue());
1002   - }
1003 1003 else
1004 1004 {
1005 1005 throw QPDFExc(qpdf_e_damaged_pdf, input->getName(),
... ...