From 8eca9d8fd988d6834f3d59554277ff1d9f05d8c9 Mon Sep 17 00:00:00 2001 From: m-holger Date: Thu, 27 Jan 2022 14:03:32 +0000 Subject: Fix QPDFObjectHandle::isOrHasName Ensure isOrHasName returns true if object is an array and the name is present anywhere in the array. --- libqpdf/QPDFObjectHandle.cc | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'libqpdf/QPDFObjectHandle.cc') 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 -- cgit v1.2.3-54-g00ecf