2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-22 10:58:58 +00:00

Add test for attempts to copy foreign /Pages object

This commit is contained in:
m-holger 2023-09-03 10:50:06 +01:00
parent 0046de0852
commit ca79fcb26e
2 changed files with 5 additions and 0 deletions

View File

@ -1 +1,2 @@
WARNING: minimal.pdf (object 6 0, offset 556): Unexpected reference to /Pages object while copying foreign object. Replacing with Null object.
test 25 done

View File

@ -954,6 +954,8 @@ test_25(QPDF& pdf, char const* arg2)
// Copy qtest without crossing page boundaries. Should get O1
// and O2 and their streams but not O3 or any other pages.
// Also verify that attempts to copy /Pages objects return null.
assert(arg2 != nullptr);
{
// Make sure original PDF is out of scope when we write.
@ -961,6 +963,8 @@ test_25(QPDF& pdf, char const* arg2)
oldpdf.processFile(arg2);
QPDFObjectHandle qtest = oldpdf.getTrailer().getKey("/QTest");
pdf.getTrailer().replaceKey("/QTest", pdf.copyForeignObject(qtest));
assert(pdf.copyForeignObject(oldpdf.getRoot().getKey("/Pages")).isNull());
}
QPDFWriter w(pdf, "a.pdf");