From 723efe238068731277169790afe3cc357e09d44a Mon Sep 17 00:00:00 2001 From: Konrad Abicht Date: Wed, 13 Mar 2024 10:12:38 +0100 Subject: [PATCH] added a test to exploit #659 --- .../Integration/RawData/FilterHelperTest.php | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/PHPUnit/Integration/RawData/FilterHelperTest.php b/tests/PHPUnit/Integration/RawData/FilterHelperTest.php index c2f99e12..d3829a64 100644 --- a/tests/PHPUnit/Integration/RawData/FilterHelperTest.php +++ b/tests/PHPUnit/Integration/RawData/FilterHelperTest.php @@ -141,6 +141,29 @@ public function testDecodeFilterFlateDecodeCRC32Checksum(): void self::assertStringContainsString('Two Westbrook Corporate Center Suite 500', $document->getText()); } + /** + * Check if function runs into a "gzuncompress(): data error". + * + * @see https://github.com/smalot/pdfparser/issues/659 + */ + public function testDecodeFilterFlateDecodeGzUncompressDataErrorIssue659(): void + { + $data = '�s��8�S4z�2A�ٮ�������n�O��)q,�ӕ�ik�7l�B:�������3�|�L'; + + $subjectUnderTest = new FilterHelper(); + + // ,--- currently throws exception: decodeFilterFlateDecode: invalid data + // , + // , + $subjectUnderTest->decodeFilter('FlateDecode', $data, 1000000); + + // we expect an error with "gzuncompress(): data error" here + } + /** * How does function behave if an unknown filter name was given. */