Commit 29e48a84 by wbond

Updated by_magic() to work with Ruby 2.0 - tries to call .b on string so they…

Updated by_magic() to work with Ruby 2.0 - tries to call .b on string so they are compared as binary
parent 92df9fef
...@@ -109,12 +109,17 @@ class MimeMagic ...@@ -109,12 +109,17 @@ class MimeMagic
def self.magic_match(io, matches) def self.magic_match(io, matches)
matches.any? do |offset, value, children| matches.any? do |offset, value, children|
value = value.b if value.respond_to?(:b)
match = if Range === offset match = if Range === offset
io.seek(offset.begin) io.seek(offset.begin)
io.read(offset.end - offset.begin + value.length).include?(value) io_val = io.read(offset.end - offset.begin + value.length)
io_val = io_val.b if io_val.respond_to?(:b)
io_val.include?(value)
else else
io.seek(offset) io.seek(offset)
value == io.read(value.length) io_val = io.read(value.length)
io_val = io_val.b if io_val.respond_to?(:b)
value == io_val
end end
match && (!children || magic_match(io, children)) match && (!children || magic_match(io, children))
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment