Skip to content

Commit

Permalink
test: add unit test for Issue 727
Browse files Browse the repository at this point in the history
  • Loading branch information
tkegan committed Jul 25, 2024
1 parent a24b6da commit 5c47852
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Binary file added samples/bugs/Issue727.pdf
Binary file not shown.
20 changes: 20 additions & 0 deletions tests/PHPUnit/Integration/RawData/RawDataParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,24 @@ public function testGetXrefDataIssue673(): void

self::assertStringContainsString('6 rue des Goutais', $text);
}

/**
* Handle self referencing xref
*
* It seems that some pdf creators output `Prev 0` when there is no previous
* xref
*
* @see https://github.com/smalot/pdfparser/pull/727
*/
public function testDecodeXrefIssue727(): void
{
$filename = $this->rootDir.'/samples/bugs/Issue727.pdf';

// Parsing this document would previously cause an infinite loop
$parser = $this->getParserInstance();
$document = $parser->parseFile($filename);
$text = $document->getText();

self::assertStringContainsString('', $text);
}
}

0 comments on commit 5c47852

Please sign in to comment.