mirror of
https://github.com/qpdf/qpdf.git
synced 2025-01-05 16:12:13 +00:00
Fix QPDFObjectHandle::isOrHasName
Ensure isOrHasName returns true if object is an array and the name is present anywhere in the array.
This commit is contained in:
parent
07db3200cb
commit
8eca9d8fd9
@ -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
|
||||
|
@ -3128,6 +3128,15 @@ static void test_82(QPDF& pdf, char const* arg2)
|
||||
assert(stream.isStreamOfType("/ObjStm"));
|
||||
assert(! stream.isStreamOfType("/Test"));
|
||||
assert(! pdf.getObjectByID(2,0).isStreamOfType("/Pages"));
|
||||
auto array = QPDFObjectHandle::parse("[/Blah /Blaah /Blaaah]");
|
||||
assert(array.isOrHasName("/Blah"));
|
||||
assert(array.isOrHasName("/Blaaah"));
|
||||
assert(! array.isOrHasName("/Blaaaah"));
|
||||
assert(array.getArrayItem(0).isOrHasName("/Blah"));
|
||||
assert(! array.getArrayItem(1).isOrHasName("/Blah"));
|
||||
array = QPDFObjectHandle::parse("[]");
|
||||
assert(! array.isOrHasName("/Blah"));
|
||||
assert(! str.isOrHasName("/Marvin"));
|
||||
}
|
||||
|
||||
void runtest(int n, char const* filename1, char const* arg2)
|
||||
|
Loading…
Reference in New Issue
Block a user