smalot / smalot/pdfparser

Hangs on corrupt file

Open
#158 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
2.7k
Forks
579
Avg merge
2m
Merged PRs (30d)
1

Description

I download a PDF file, and run the following code... which seems to just hang.
$parser = new PdfParser();
$pdf = $parser->parseFile( $saved_file );
$details = $pdf->getDetails();

When I download the file via a web-browser and try to open it, it says the PDF is corrupt.

Shouldn't this throw and exception or return NULL on corrupt files?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at PdfParser->parseFile(), using the corrupt PDF described in the report, and inspect how getDetails() behaves afterward. Confirm the expected handling for corrupt files—an exception or NULL—and verify that the parser no longer hangs.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.