Commit 12db09898e70fcdc308cf500a95fb166e696b6dc
1 parent
701b518d
Don't interpret word tokens in content streams (fixes #82)
Showing
2 changed files
with
8 additions
and
5 deletions
ChangeLog
| 1 | 2017-07-26 Jay Berkenbilt <ejb@ql.org> | 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 | * Detect infinite loops while resolving objects. This could happen | 6 | * Detect infinite loops while resolving objects. This could happen |
| 4 | if something inside an object that had to be resolved during | 7 | if something inside an object that had to be resolved during |
| 5 | parsing, such as a stream length, recursively referenced the | 8 | parsing, such as a stream length, recursively referenced the |
libqpdf/QPDFObjectHandle.cc
| @@ -964,7 +964,11 @@ QPDFObjectHandle::parseInternal(PointerHolder<InputSource> input, | @@ -964,7 +964,11 @@ QPDFObjectHandle::parseInternal(PointerHolder<InputSource> input, | ||
| 964 | case QPDFTokenizer::tt_word: | 964 | case QPDFTokenizer::tt_word: |
| 965 | { | 965 | { |
| 966 | std::string const& value = token.getValue(); | 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 | (olist.size() >= 2) && | 972 | (olist.size() >= 2) && |
| 969 | (! olist.at(olist.size() - 1).isIndirect()) && | 973 | (! olist.at(olist.size() - 1).isIndirect()) && |
| 970 | (olist.at(olist.size() - 1).isInteger()) && | 974 | (olist.at(olist.size() - 1).isInteger()) && |
| @@ -996,10 +1000,6 @@ QPDFObjectHandle::parseInternal(PointerHolder<InputSource> input, | @@ -996,10 +1000,6 @@ QPDFObjectHandle::parseInternal(PointerHolder<InputSource> input, | ||
| 996 | input->seek(input->getLastOffset(), SEEK_SET); | 1000 | input->seek(input->getLastOffset(), SEEK_SET); |
| 997 | empty = true; | 1001 | empty = true; |
| 998 | } | 1002 | } |
| 999 | - else if (content_stream) | ||
| 1000 | - { | ||
| 1001 | - object = QPDFObjectHandle::newOperator(token.getValue()); | ||
| 1002 | - } | ||
| 1003 | else | 1003 | else |
| 1004 | { | 1004 | { |
| 1005 | throw QPDFExc(qpdf_e_damaged_pdf, input->getName(), | 1005 | throw QPDFExc(qpdf_e_damaged_pdf, input->getName(), |