prawnpdf/prawn — pull request #573 by fidothe (2013-11-08 18:47:52+00:00)
Title: Refactor so images via Pathname are read in binmode

* Separate out image IO opening and verification logic
* test that embedded images parse correctly (this was the problem that
was being masked before)
* Add simple matcher to tidy up checking XObject parseability
* fixes #570:

Pathname instances respond to #read but not #binmode, and the old code
was assuming that anything which responded to #read was an IO, with the
result that Pathname instances were beign treated as IO's and getting
read called on them, bypassing File.binread (things responding
to #binmode have that called so with a real IO it would have #read
called after it had been put into binmode...

The fix is simple enough: treat everything that responds to binmode as
an IO (IO's and Files), and anything else treat as a path, and open it
'rb'.

(This ought to work on 1.8 too)