Avoid detecting CR2 and CRW as tiff. Use own fakeweb. Fixes #104

This commit is contained in:
Stephen Sykes 2018-09-09 22:37:59 +03:00
parent 15bc4111c4
commit aa097226e8
5 changed files with 19 additions and 3 deletions

View File

@ -20,7 +20,7 @@ Gem::Specification.new do |s|
s.require_paths = ["lib"]
s.rubygems_version = %q{1.3.6}
s.summary = %q{FastImage - Image info fast}
s.add_development_dependency 'fakeweb', '~> 1.3'
s.add_development_dependency 'fakeweb-fi', '~> 1.3'
# Note rake 11 drops support for ruby 1.9.2
s.add_development_dependency('rake', '~> 10.5')
s.add_development_dependency('rdoc')

View File

@ -483,7 +483,12 @@ class FastImage
when 0x89.chr + "P"
:png
when "II", "MM"
:tiff
case @stream.peek(11)[8..10]
when "APC", "CR\002"
nil # do not recognise CRW or CR2 as tiff
else
:tiff
end
when '8B'
:psd
when "\0\0"

BIN
test/fixtures/a.CR2 vendored Normal file

Binary file not shown.

BIN
test/fixtures/a.CRW vendored Normal file

Binary file not shown.

View File

@ -41,7 +41,9 @@ GoodFixtures = {
BadFixtures = [
"faulty.jpg",
"test_rgb.ct",
"test.xml"
"test.xml",
"a.CR2",
"a.CRW"
]
# 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
@ -409,4 +411,13 @@ class FastImageTest < Test::Unit::TestCase
def test_should_return_content_length_for_data_uri_images
assert_equal DataUriImageContentLength, FastImage.new(DataUriImage).content_length
end
def test_canon_raw_formats_are_not_recognised_as_tiff
assert_raises(FastImage::UnknownImageType) do
FastImage.size(TestUrl + "a.CR2", :raise_on_failure=>true)
end
assert_raises(FastImage::UnknownImageType) do
FastImage.size(TestUrl + "a.CRW", :raise_on_failure=>true)
end
end
end