yob / pdf-reader

The PDF::Reader library implements a PDF parser conforming as much as possible to the PDF specification from Adobe.
MIT License
1.81k stars 271 forks source link

when zlib inflation fails, try again with the final byte left off #341

Closed yob closed 3 years ago

yob commented 3 years ago

I've seen PDFs in the wild where leaving off the final byte allows the ruby zlib bindings to successfully inflate the stream.

The spec I've changed here is one example I've kept around for over 10 years, but another was shared to the pdf-reader mailing list today.

The only downside to this change is the MalformedPDFError exception that's raised no longer references the underlying zlib exception. I think that's acceptable in return for being able to parse more files though.