Commit d11553e49ab9ecadd1203aeead3b968613092ca8
1 parent
4974090f
Enhance `QPDFEmbeddedFileDocumentHelper` with stricter validation and value checking
- Added `validate()` invocation to `m->embedded_files`. - Introduced `value_validator` to ensure only dictionaries are accepted in `EmbeddedFiles`. - Enabled consistent value validation and key validation logic.
Showing
1 changed file
with
8 additions
and
2 deletions
libqpdf/QPDFEmbeddedFileDocumentHelper.cc
| @@ -48,7 +48,12 @@ QPDFEmbeddedFileDocumentHelper::QPDFEmbeddedFileDocumentHelper(QPDF& qpdf) : | @@ -48,7 +48,12 @@ QPDFEmbeddedFileDocumentHelper::QPDFEmbeddedFileDocumentHelper(QPDF& qpdf) : | ||
| 48 | if (names.isDictionary()) { | 48 | if (names.isDictionary()) { |
| 49 | auto embedded_files = names.getKey("/EmbeddedFiles"); | 49 | auto embedded_files = names.getKey("/EmbeddedFiles"); |
| 50 | if (embedded_files.isDictionary()) { | 50 | if (embedded_files.isDictionary()) { |
| 51 | - m->embedded_files = std::make_unique<QPDFNameTreeObjectHelper>(embedded_files, qpdf); | 51 | + m->embedded_files = std::make_unique<QPDFNameTreeObjectHelper>( |
| 52 | + embedded_files, | ||
| 53 | + qpdf, | ||
| 54 | + [](QPDFObjectHandle const& o) -> bool { return o.isDictionary(); }, | ||
| 55 | + true); | ||
| 56 | + m->embedded_files->validate(); | ||
| 52 | } | 57 | } |
| 53 | } | 58 | } |
| 54 | } | 59 | } |
| @@ -74,7 +79,8 @@ QPDFEmbeddedFileDocumentHelper::initEmbeddedFiles() | @@ -74,7 +79,8 @@ QPDFEmbeddedFileDocumentHelper::initEmbeddedFiles() | ||
| 74 | if (!embedded_files.isDictionary()) { | 79 | if (!embedded_files.isDictionary()) { |
| 75 | auto nth = QPDFNameTreeObjectHelper::newEmpty(qpdf); | 80 | auto nth = QPDFNameTreeObjectHelper::newEmpty(qpdf); |
| 76 | names.replaceKey("/EmbeddedFiles", nth.getObjectHandle()); | 81 | names.replaceKey("/EmbeddedFiles", nth.getObjectHandle()); |
| 77 | - m->embedded_files = std::make_unique<QPDFNameTreeObjectHelper>(nth); | 82 | + m->embedded_files = std::make_unique<QPDFNameTreeObjectHelper>( |
| 83 | + nth, qpdf, [](QPDFObjectHandle const& o) -> bool { return o.isDictionary(); }, true); | ||
| 78 | } | 84 | } |
| 79 | } | 85 | } |
| 80 | 86 |