summaryrefslogtreecommitdiff
path: root/xmlsecurity
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2017-04-13 18:09:32 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-04-14 10:24:05 +0200
commit9697c0275a4c36117a95ccb702c16b3ff7716cfd (patch)
treec5b614bc5ec92698c4aa2321ff99d6bb26f09e10 /xmlsecurity
parent5387e8c8dc2484a6a30f0792e168c7621d1a5d50 (diff)
vcl PDF import: don't assume larger offset -> newer trailer
Usually when the PDF file contains incremental updates the updates are appended at the end of the document. But this is not required, the various trailers can be in any order. Make sure that we look at the last trailer (logically last, not the one with the largest file offset) when looking for pages. Reviewed-on: https://gerrit.libreoffice.org/36527 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org> (cherry picked from commit f15a69bd57e578ca607f14cb62f29a16986b96e6) Conflicts: xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx Change-Id: Idcd85a7c6bbf08c9436dd73933d79cdb683f482c
Diffstat (limited to 'xmlsecurity')
-rw-r--r--xmlsecurity/qa/unit/pdfsigning/data/tdf107149.pdf97
-rw-r--r--xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx6
2 files changed, 103 insertions, 0 deletions
diff --git a/xmlsecurity/qa/unit/pdfsigning/data/tdf107149.pdf b/xmlsecurity/qa/unit/pdfsigning/data/tdf107149.pdf
new file mode 100644
index 000000000000..db063f366a93
--- /dev/null
+++ b/xmlsecurity/qa/unit/pdfsigning/data/tdf107149.pdf
@@ -0,0 +1,97 @@
+%PDF-1.2
+%âãÏÓ
+3 0 obj
+<<
+/Length 61
+>>
+stream
+ BT
+ /F1 24 Tf
+ 1 0 0 1 260 254 Tm
+ (Hello Worl2)Tj
+ ET
+
+endstream
+endobj xref
+0 7
+0000000000 65535 f
+0000000312 00000 n
+0000000532 00000 n
+0000000015 00000 n
+0000000660 00000 n
+0000000578 00000 n
+0000000743 00000 n
+trailer
+
+<<
+/Root 6 0 R
+/Size 7
+>>
+1 0 obj
+<<
+/Resources 2 0 R
+/Contents 3 0 R
+/Parent 4 0 R
+/Type /Page
+/MediaBox [0 0 612 446]
+>>
+endobj
+3 0 obj
+<<
+/Length 61
+>>
+stream
+ BT
+ /F1 24 Tf
+ 1 0 0 1 260 254 Tm
+ (Hello World)Tj
+ ET
+
+endstream
+endobj
+2 0 obj
+<<
+/Font
+<<
+/F1 5 0 R
+>>
+>>
+endobj
+5 0 obj
+<<
+/Subtype /Type1
+/Name /F1
+/Type /Font
+/BaseFont /Helvetica
+>>
+endobj
+4 0 obj
+<<
+/Kids [1 0 R]
+/Type /Pages
+/MediaBox [0 0 612 446]
+/Count 1
+>>
+endobj
+6 0 obj
+<<
+/Type /Catalog
+/Pages 4 0 R
+>>
+endobj xref
+0 7
+0000000000 65535 f
+0000000015 00000 n
+0000000235 00000 n
+0000000121 00000 n
+0000000363 00000 n
+0000000281 00000 n
+0000000446 00000 n
+trailer
+
+<<
+/Size 7
+>>
+startxref
+128
+%%EOF
diff --git a/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx b/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx
index 69916d677a98..015e5a02924e 100644
--- a/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx
+++ b/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx
@@ -395,6 +395,7 @@ void PDFSigningTest::testTokenize()
OUStringLiteral("noeol.pdf"),
// File that's intentionally smaller than 1024 bytes.
OUStringLiteral("small.pdf"),
+ OUStringLiteral("tdf107149.pdf"),
};
for (const auto& rName : aNames)
@@ -403,6 +404,11 @@ void PDFSigningTest::testTokenize()
vcl::filter::PDFDocument aDocument;
// Just make sure the tokenizer finishes without an error, don't look at the signature.
CPPUNIT_ASSERT(aDocument.Read(aStream));
+
+ OUString aNoPages("tdf107149.pdf");
+ if (aNoPages == rName)
+ // This failed, page list was empty.
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aDocument.GetPages().size());
}
}