lib/chunky_png/datastream.rb in chunky_png-1.2.7 vs lib/chunky_png/datastream.rb in chunky_png-1.2.8
- old
+ new
@@ -9,11 +9,11 @@
#
# @see ChunkyPNG::Chunk
class Datastream
# The signature that each PNG file or stream should begin with.
- SIGNATURE = [137, 80, 78, 71, 13, 10, 26, 10].pack('C8')
+ SIGNATURE = ChunkyPNG.force_binary([137, 80, 78, 71, 13, 10, 26, 10].pack('C8'))
# The header chunk of this datastream.
# @return [ChunkyPNG::Chunk::Header]
attr_accessor :header_chunk
@@ -96,11 +96,11 @@
# @param [IO] io The stream to read the PNG signature from.
# @raise [RuntimeError] An exception is raised if the PNG signature is not found at
# the beginning of the stream.
def verify_signature!(io)
signature = io.read(ChunkyPNG::Datastream::SIGNATURE.length)
- unless signature == ChunkyPNG::Datastream::SIGNATURE
- raise ChunkyPNG::SignatureMismatch, "PNG signature not found!"
+ unless ChunkyPNG.force_binary(signature) == ChunkyPNG::Datastream::SIGNATURE
+ raise ChunkyPNG::SignatureMismatch, "PNG signature not found, found #{signature.inspect} instead of #{ChunkyPNG::Datastream::SIGNATURE.inspect}!"
end
end
end
##################################################################################