aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDFObjectHandle.cc
diff options
context:
space:
mode:
authorm-holger <m-holger@kubitscheck.org>2022-01-27 15:03:32 +0100
committerJay Berkenbilt <jberkenbilt@users.noreply.github.com>2022-01-27 16:35:39 +0100
commit8eca9d8fd988d6834f3d59554277ff1d9f05d8c9 (patch)
treec9cc6c0986e94c93cfda282acf8cda5738a1b97f /libqpdf/QPDFObjectHandle.cc
parent07db3200cb0ef058b8a66ece8d9757adfba49fd1 (diff)
downloadqpdf-8eca9d8fd988d6834f3d59554277ff1d9f05d8c9.tar.zst
Fix QPDFObjectHandle::isOrHasName
Ensure isOrHasName returns true if object is an array and the name is present anywhere in the array.
Diffstat (limited to 'libqpdf/QPDFObjectHandle.cc')
-rw-r--r--libqpdf/QPDFObjectHandle.cc18
1 files changed, 15 insertions, 3 deletions
diff --git a/libqpdf/QPDFObjectHandle.cc b/libqpdf/QPDFObjectHandle.cc
index f8d52a7b..e5b9a3e3 100644
--- a/libqpdf/QPDFObjectHandle.cc
+++ b/libqpdf/QPDFObjectHandle.cc
@@ -1055,9 +1055,21 @@ QPDFObjectHandle::getDictAsMap()
bool
QPDFObjectHandle::isOrHasName(std::string const& value)
{
- return isNameAndEquals(value) ||
- (isArray() && (getArrayNItems() > 0) &&
- getArrayItem(0).isNameAndEquals(value));
+ if (isNameAndEquals(value))
+ {
+ return true;
+ }
+ else if (isArray())
+ {
+ for (auto& item: aitems())
+ {
+ if (item.isNameAndEquals(value))
+ {
+ return true;
+ }
+ }
+ }
+ return false;
}
void