Merge pull request #62 from jvenezia/master

raise UnknownImageType when file is non-svg xml
This commit is contained in:
Stephen Sykes 2015-12-02 10:30:14 +02:00
commit ca29078b07
3 changed files with 18 additions and 2 deletions

View File

@ -436,8 +436,14 @@ class FastImage
else
raise UnknownImageType
end
when "<?", "<s"
when "<s"
:svg
when "<?"
if @stream.peek(100).include?("<svg")
:svg
else
raise UnknownImageType
end
else
raise UnknownImageType
end

3
test/fixtures/test.xml vendored Normal file
View File

@ -0,0 +1,3 @@
<?xml version="1.0"?>
<html xmlns="http://www.w3.org/1999/xhtml">
</html>

View File

@ -37,7 +37,8 @@ GoodFixtures = {
BadFixtures = [
"faulty.jpg",
"test_rgb.ct"
"test_rgb.ct",
"test.xml"
]
# man.ico courtesy of http://www.iconseeker.com/search-icon/artists-valley-sample/business-man-blue.html
# test_rgb.ct courtesy of http://fileformats.archiveteam.org/wiki/Scitex_CT
@ -122,6 +123,12 @@ class FastImageTest < Test::Unit::TestCase
end
end
def test_should_raise_unknown_image_typ_when_file_is_non_svg_xml
assert_raises(FastImage::UnknownImageType) do
FastImage.size(TestUrl + "test.xml", :raise_on_failure=>true)
end
end
def test_should_report_type_correctly_for_local_files
GoodFixtures.each do |fn, info|
assert_equal info[0], FastImage.type(File.join(FixturePath, fn))