Fix for bug where 0xff is followed by second 0xff in jpg

This commit is contained in:
Stephen Sykes 2010-11-11 01:29:22 +02:00
parent 7fb2e5787d
commit ab2efbf2ff
5 changed files with 9 additions and 10 deletions

View File

@ -1,5 +1,5 @@
---
:patch: 6
:patch: 8
:major: 1
:build:
:minor: 2

View File

@ -1,15 +1,10 @@
# Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{fastimage}
s.version = "1.2.7"
s.version = "1.2.8"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Stephen Sykes"]
s.date = %q{2010-07-14}
s.date = %q{2010-11-11}
s.description = %q{FastImage finds the size or type of an image given its uri by fetching as little as needed.}
s.email = %q{sdsykes@gmail.com}
s.extra_rdoc_files = [
@ -29,6 +24,7 @@ Gem::Specification.new do |s|
"test/fixtures/test.jpg",
"test/fixtures/test.png",
"test/fixtures/test2.jpg",
"test/fixtures/test3.jpg",
"test/test.rb"
]
s.homepage = %q{http://github.com/sdsykes/fastimage}

View File

@ -257,13 +257,15 @@ class FastImage
get_chars(2)
:started
when :started
get_byte == 0xFF ? :sof : :started
get_byte == 0xFF ? :sof : :started
when :sof
c = get_byte
if (0xe0..0xef).include?(c)
:skipframe
elsif [0xC0..0xC3, 0xC5..0xC7, 0xC9..0xCB, 0xCD..0xCF].detect {|r| r.include? c}
:readsize
elsif c == 0xFF
:sof
else
:skipframe
end

BIN
test/fixtures/test3.jpg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View File

@ -15,7 +15,8 @@ GoodFixtures = {
"test.gif"=>[:gif, [17, 32]],
"test.jpg"=>[:jpeg, [882, 470]],
"test.png"=>[:png, [30, 20]],
"test2.jpg"=>[:jpeg, [250, 188]]
"test2.jpg"=>[:jpeg, [250, 188]],
"test3.jpg"=>[:jpeg, [630,367]]
}
BadFixtures = [