mirror of
https://github.com/sdsykes/fastimage.git
synced 2025-12-30 00:05:02 -05:00
raise UnknownImageType when file is non-svg xml
This commit is contained in:
parent
f77a2b80bb
commit
4c1905fd66
@ -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
3
test/fixtures/test.xml
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
<?xml version="1.0"?>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
</html>
|
||||
@ -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))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user