From 72bfbea970960a77420581ad60bdcad69c70a1f8 Mon Sep 17 00:00:00 2001 From: Maximilian Kresse <545671+MaximilianKresse@users.noreply.github.com> Date: Wed, 11 Mar 2026 09:45:08 +0100 Subject: [PATCH 1/7] Improved release action description --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3ef68f6..e0bbb05 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,7 +2,7 @@ on: workflow_dispatch: inputs: version: - description: 'Version' + description: 'Version (x.x.x)' required: true name: Create release From 508ea88eb869739a1e0153c289e53395d20b9b66 Mon Sep 17 00:00:00 2001 From: Jan Slabon Date: Thu, 12 Mar 2026 17:22:12 +0100 Subject: [PATCH 2/7] Fixed generation of internal reader-id in `FpdiTrait` --- src/FpdiTrait.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/FpdiTrait.php b/src/FpdiTrait.php index 4879a05..7063535 100644 --- a/src/FpdiTrait.php +++ b/src/FpdiTrait.php @@ -172,7 +172,8 @@ protected function getPdfReaderId( ); } - /** @noinspection OffsetOperationsInspection */ + $id = \md5($id . '|' . \print_r($parserParams, true)); + if (isset($this->readers[$id])) { return $id; } @@ -187,7 +188,6 @@ protected function getPdfReaderId( } $reader = new PdfReader($this->getPdfParserInstance($streamReader, $parserParams)); - /** @noinspection OffsetOperationsInspection */ $this->readers[$id] = $reader; return $id; From 35ee7871f7cc898a364979492aeab38be0f6c6a3 Mon Sep 17 00:00:00 2001 From: Jan Slabon Date: Thu, 12 Mar 2026 17:22:36 +0100 Subject: [PATCH 3/7] Added test for reader-id behavior --- tests/functional/FpdiTraitTest.php | 37 +++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/tests/functional/FpdiTraitTest.php b/tests/functional/FpdiTraitTest.php index 395ba8a..45e953b 100644 --- a/tests/functional/FpdiTraitTest.php +++ b/tests/functional/FpdiTraitTest.php @@ -3,7 +3,10 @@ namespace setasign\Fpdi\functional; use PHPUnit\Framework\TestCase; +use setasign\Fpdi\FpdfTrait; use setasign\Fpdi\Fpdi; +use setasign\Fpdi\FpdiTrait; +use setasign\Fpdi\PdfParser\CrossReference\CrossReferenceException; use setasign\Fpdi\PdfParser\Type\PdfArray; use setasign\Fpdi\PdfParser\Type\PdfBoolean; use setasign\Fpdi\PdfParser\Type\PdfDictionary; @@ -16,7 +19,6 @@ use setasign\Fpdi\PdfParser\Type\PdfStream; use setasign\Fpdi\PdfParser\Type\PdfString; use setasign\Fpdi\PdfParser\Type\PdfToken; -use setasign\Fpdi\PdfParser\Type\PdfType; class FpdiTraitTest extends TestCase { @@ -359,6 +361,39 @@ public function testWritingOfIndirectObjectsAndReferences() "endobj\n", $result ); + } + + public function testSetSourceFileCalledTwiceWithEncryptedDocument() + { + $path = __DIR__ . '/../_files/pdfs/encrypted/AES256-R6-u=user-o=owner.pdf'; + $pdf = new Fpdi(); + $this->expectException(CrossReferenceException::class); + $this->expectExceptionCode(CrossReferenceException::ENCRYPTED); + try { + $pdf->setSourceFile($path); + } catch (\Throwable $e) { + $pdf->setSourceFileWithParserParams($path, ['password' => 'neverUsed']); + } + } + public function testInternalReaderIdBehavior() + { + $class = new class() { + use FpdiTrait; + + public function debugGetPdfReaderId($file, array $parserParams = []) + { + return $this->getPdfReaderId($file, $parserParams); + } + }; + + $a = $class->debugGetPdfReaderId(__FILE__, []); + $b = $class->debugGetPdfReaderId(__FILE__, []); + $this->assertSame($a, $b); + + $c = $class->debugGetPdfReaderId(__FILE__, ['a']); + $this->assertNotSame($b, $c); + $d = $class->debugGetPdfReaderId(__FILE__, ['b']); + $this->assertNotSame($c, $d); } } \ No newline at end of file From 2dea0db264552e255d3ecadff20f7304b2eec956 Mon Sep 17 00:00:00 2001 From: Jan Slabon Date: Thu, 12 Mar 2026 17:39:05 +0100 Subject: [PATCH 4/7] Clear `Tokenizer` stack in `CrossReference` constructor --- src/PdfParser/CrossReference/CrossReference.php | 3 +++ tests/functional/FpdiTraitTest.php | 1 + 2 files changed, 4 insertions(+) diff --git a/src/PdfParser/CrossReference/CrossReference.php b/src/PdfParser/CrossReference/CrossReference.php index 2bdb629..36bd7ec 100644 --- a/src/PdfParser/CrossReference/CrossReference.php +++ b/src/PdfParser/CrossReference/CrossReference.php @@ -56,6 +56,9 @@ class CrossReference */ public function __construct(PdfParser $parser, $fileHeaderOffset = 0) { + // clear the token stack, if the parser instance is re-used + $parser->getTokenizer()->clearStack(); + $this->parser = $parser; $this->fileHeaderOffset = $fileHeaderOffset; diff --git a/tests/functional/FpdiTraitTest.php b/tests/functional/FpdiTraitTest.php index 45e953b..6234642 100644 --- a/tests/functional/FpdiTraitTest.php +++ b/tests/functional/FpdiTraitTest.php @@ -369,6 +369,7 @@ public function testSetSourceFileCalledTwiceWithEncryptedDocument() $pdf = new Fpdi(); $this->expectException(CrossReferenceException::class); $this->expectExceptionCode(CrossReferenceException::ENCRYPTED); + try { $pdf->setSourceFile($path); } catch (\Throwable $e) { From 96d960a5aae5ad386e97e0fe2958dd5cbbf6609b Mon Sep 17 00:00:00 2001 From: Jan Slabon Date: Fri, 13 Mar 2026 08:35:27 +0100 Subject: [PATCH 5/7] Update composer.lock --- composer.lock | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/composer.lock b/composer.lock index 593d478..eda5816 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "afc3b0a5f6ee0971c663a3426c2dfd0f", + "content-hash": "ee89192af2f70a299268b1694de94bd3", "packages": [], "packages-dev": [ { @@ -494,29 +494,29 @@ }, { "name": "phpunit/php-token-stream", - "version": "3.1.3", + "version": "4.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "9c1da83261628cb24b6a6df371b6e312b3954768" + "reference": "a853a0e183b9db7eed023d7933a858fa1c8d25a3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/9c1da83261628cb24b6a6df371b6e312b3954768", - "reference": "9c1da83261628cb24b6a6df371b6e312b3954768", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/a853a0e183b9db7eed023d7933a858fa1c8d25a3", + "reference": "a853a0e183b9db7eed023d7933a858fa1c8d25a3", "shasum": "" }, "require": { "ext-tokenizer": "*", - "php": ">=7.1" + "php": "^7.3 || ^8.0" }, "require-dev": { - "phpunit/phpunit": "^7.0" + "phpunit/phpunit": "^9.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.1-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -541,7 +541,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-token-stream/issues", - "source": "https://github.com/sebastianbergmann/php-token-stream/tree/3.1.3" + "source": "https://github.com/sebastianbergmann/php-token-stream/tree/master" }, "funding": [ { @@ -550,7 +550,7 @@ } ], "abandoned": true, - "time": "2021-07-26T12:15:06+00:00" + "time": "2020-08-04T08:28:15+00:00" }, { "name": "phpunit/phpunit", @@ -1615,16 +1615,16 @@ }, { "name": "tecnickcom/tcpdf", - "version": "6.10.1", + "version": "6.11.2", "source": { "type": "git", "url": "https://github.com/tecnickcom/TCPDF.git", - "reference": "7a2701251e5d52fc3d508fd71704683eb54f5939" + "reference": "e1e2ade18e574e963473f53271591edd8c0033ec" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/tecnickcom/TCPDF/zipball/7a2701251e5d52fc3d508fd71704683eb54f5939", - "reference": "7a2701251e5d52fc3d508fd71704683eb54f5939", + "url": "https://api.github.com/repos/tecnickcom/TCPDF/zipball/e1e2ade18e574e963473f53271591edd8c0033ec", + "reference": "e1e2ade18e574e963473f53271591edd8c0033ec", "shasum": "" }, "require": { @@ -1674,7 +1674,7 @@ ], "support": { "issues": "https://github.com/tecnickcom/TCPDF/issues", - "source": "https://github.com/tecnickcom/TCPDF/tree/6.10.1" + "source": "https://github.com/tecnickcom/TCPDF/tree/6.11.2" }, "funding": [ { @@ -1682,7 +1682,7 @@ "type": "custom" } ], - "time": "2025-11-21T10:58:21+00:00" + "time": "2026-03-03T08:58:10+00:00" }, { "name": "theseer/tokenizer", @@ -1741,7 +1741,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": "^7.2 || ^8.0", + "php": ">=7.2 <=8.5.99999", "ext-zlib": "*" }, "platform-dev": [], From be77719f3d539e11511bbd56d434437cdb5165e6 Mon Sep 17 00:00:00 2001 From: Jan Slabon Date: Fri, 13 Mar 2026 08:35:33 +0100 Subject: [PATCH 6/7] Update FpdiTraitTest.php --- tests/functional/FpdiTraitTest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/functional/FpdiTraitTest.php b/tests/functional/FpdiTraitTest.php index 6234642..ef3d04a 100644 --- a/tests/functional/FpdiTraitTest.php +++ b/tests/functional/FpdiTraitTest.php @@ -396,5 +396,8 @@ public function debugGetPdfReaderId($file, array $parserParams = []) $this->assertNotSame($b, $c); $d = $class->debugGetPdfReaderId(__FILE__, ['b']); $this->assertNotSame($c, $d); + + $e = $class->debugGetPdfReaderId(__DIR__ . '/../_files/pdfs/normal-xref.pdf', ['b']); + $this->assertNotSame($d, $e); } } \ No newline at end of file From 58d75a0d9f8390dc2c0472638029561de759f413 Mon Sep 17 00:00:00 2001 From: Jan Slabon Date: Fri, 13 Mar 2026 09:27:11 +0100 Subject: [PATCH 7/7] Update FpdiTraitTest.php --- tests/functional/FpdiTraitTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/functional/FpdiTraitTest.php b/tests/functional/FpdiTraitTest.php index ef3d04a..ccbfbde 100644 --- a/tests/functional/FpdiTraitTest.php +++ b/tests/functional/FpdiTraitTest.php @@ -3,7 +3,6 @@ namespace setasign\Fpdi\functional; use PHPUnit\Framework\TestCase; -use setasign\Fpdi\FpdfTrait; use setasign\Fpdi\Fpdi; use setasign\Fpdi\FpdiTrait; use setasign\Fpdi\PdfParser\CrossReference\CrossReferenceException;