FIX: XML files could be detected as SVG files

This commit is contained in:
Gerhard Schlager
2020-05-26 17:07:16 +02:00
parent 4dc6504234
commit 69ee94b526
2 changed files with 61 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
# frozen_string_literal: true
# Remove when https://github.com/sdsykes/fastimage/pull/115
# has been merged. Please remove the specs as well.
class FastImage
attr_reader :original_type
private
old_parse_type = instance_method(:parse_type)
define_method(:parse_type) do
@original_type = old_parse_type.bind(self).()
if @original_type == :svg && @stream.peek(2) == "<s"
raise UnknownImageType if @stream.peek(4) != "<svg"
end
@original_type
end
end