mirror of
https://github.com/qpdf/qpdf.git
synced 2025-01-08 09:18:41 +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
|
bool
|
||||||
QPDFObjectHandle::isOrHasName(std::string const& value)
|
QPDFObjectHandle::isOrHasName(std::string const& value)
|
||||||
{
|
{
|
||||||
return isNameAndEquals(value) ||
|
if (isNameAndEquals(value))
|
||||||
(isArray() && (getArrayNItems() > 0) &&
|
{
|
||||||
getArrayItem(0).isNameAndEquals(value));
|
return true;
|
||||||
|
}
|
||||||
|
else if (isArray())
|
||||||
|
{
|
||||||
|
for (auto& item: aitems())
|
||||||
|
{
|
||||||
|
if (item.isNameAndEquals(value))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -3128,6 +3128,15 @@ static void test_82(QPDF& pdf, char const* arg2)
|
|||||||
assert(stream.isStreamOfType("/ObjStm"));
|
assert(stream.isStreamOfType("/ObjStm"));
|
||||||
assert(! stream.isStreamOfType("/Test"));
|
assert(! stream.isStreamOfType("/Test"));
|
||||||
assert(! pdf.getObjectByID(2,0).isStreamOfType("/Pages"));
|
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)
|
void runtest(int n, char const* filename1, char const* arg2)
|
||||||
|
Loading…
Reference in New Issue
Block a user