From 00df2342f9e9be90b1b24b453dba06139ee268e7 Mon Sep 17 00:00:00 2001 From: PrinsFrank <25006490+PrinsFrank@users.noreply.github.com> Date: Sat, 16 May 2026 21:00:36 +0200 Subject: [PATCH 1/2] Check dictionary and page content for encrypted documents --- tests/Samples/SamplesTest.php | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/tests/Samples/SamplesTest.php b/tests/Samples/SamplesTest.php index 1194b921..5e56311b 100644 --- a/tests/Samples/SamplesTest.php +++ b/tests/Samples/SamplesTest.php @@ -28,23 +28,24 @@ public function testSamples(FileInfo $fileInfo): void { static::assertSame($fileInfo->fileEncryptionKey, $document->fileEncryptionKey->toHex()); } else { static::assertNull($fileInfo->fileEncryptionKey); - static::assertSame($fileInfo->title, $document->getInformationDictionary()?->getTitle()); - static::assertSame($fileInfo->producer, $document->getInformationDictionary()?->getProducer()); - static::assertSame($fileInfo->author, $document->getInformationDictionary()?->getAuthor()); - static::assertSame($fileInfo->creator, $document->getInformationDictionary()?->getCreator()); - static::assertEquals($fileInfo->creationDate, $document->getInformationDictionary()?->getCreationDate()); - static::assertEquals($fileInfo->modificationDate, $document->getInformationDictionary()?->getModificationDate()); - static::assertSame(count($fileInfo->pages ?? []), $document->getNumberOfPages()); - foreach ($fileInfo->pages ?? [] as $index => $expectedPage) { - static::assertNotNull($page = $document->getPage($index + 1)); - static::assertSame(trim($expectedPage->content), trim($page->getText())); - foreach ($expectedPage->imagePaths as $imageIndex => $imagePath) { - self::assertImage( - $imagePath, - $page->getImages()[$imageIndex]->getStream()->toString(), - sprintf('Page %d, image %d', $index, $imageIndex), - ); - } + } + + static::assertSame($fileInfo->title, $document->getInformationDictionary()?->getTitle()); + static::assertSame($fileInfo->producer, $document->getInformationDictionary()?->getProducer()); + static::assertSame($fileInfo->author, $document->getInformationDictionary()?->getAuthor()); + static::assertSame($fileInfo->creator, $document->getInformationDictionary()?->getCreator()); + static::assertEquals($fileInfo->creationDate, $document->getInformationDictionary()?->getCreationDate()); + static::assertEquals($fileInfo->modificationDate, $document->getInformationDictionary()?->getModificationDate()); + static::assertSame(count($fileInfo->pages ?? []), $document->getNumberOfPages()); + foreach ($fileInfo->pages ?? [] as $index => $expectedPage) { + static::assertNotNull($page = $document->getPage($index + 1)); + static::assertSame(trim($expectedPage->content), trim($page->getText())); + foreach ($expectedPage->imagePaths as $imageIndex => $imagePath) { + self::assertImage( + $imagePath, + $page->getImages()[$imageIndex]->getStream()->toString(), + sprintf('Page %d, image %d', $index, $imageIndex), + ); } } } From d56f4695e5446da04b73fe4c3043caecd3df2837 Mon Sep 17 00:00:00 2001 From: PrinsFrank <25006490+PrinsFrank@users.noreply.github.com> Date: Tue, 19 May 2026 21:04:28 +0200 Subject: [PATCH 2/2] Fix samples content for encrypted document --- .../files/gdocs-hello-world-simple-password/contents.yml | 2 +- .../contents.yml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/Samples/files/gdocs-hello-world-simple-password/contents.yml b/tests/Samples/files/gdocs-hello-world-simple-password/contents.yml index b88aa7d4..4042b0ab 100644 --- a/tests/Samples/files/gdocs-hello-world-simple-password/contents.yml +++ b/tests/Samples/files/gdocs-hello-world-simple-password/contents.yml @@ -11,4 +11,4 @@ creationDate: null modificationDate: null pages: - - content: 'Hello world' + content: 'H ello w o r ld' diff --git a/tests/Samples/files/libreoffice-hello-world-open-password-hello/contents.yml b/tests/Samples/files/libreoffice-hello-world-open-password-hello/contents.yml index 7d42edc8..1fc1dc76 100644 --- a/tests/Samples/files/libreoffice-hello-world-open-password-hello/contents.yml +++ b/tests/Samples/files/libreoffice-hello-world-open-password-hello/contents.yml @@ -6,10 +6,10 @@ fileEncryptionKey: 50b2fc01398fa68e4b8c96bd3a10c589 title: null producer: LibreOffice 24.2 author: null -creator: null -creationDate: null +creator: Writer +creationDate: 2024-11-22T22:24:39+01:00 modificationDate: null pages: - content: |-2 - Hello World + Hello world