fastimage 2.4.1 → 2.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: acc5b0541538fa317b5401aa89c2c1f901d73b874d7f99465563ca30ee7cf724
4
- data.tar.gz: 2c78d3222232b442f6f458341db19e9a52c14db32b9c65f10c18e67caeead9a7
3
+ metadata.gz: ccdbb1bae657d9c0e935422f1194986c5b78bcc23cdf3fcba4bd741f764a3d28
4
+ data.tar.gz: 88e8d78e8958a33d36fa887a01cb55083ca424919fceaf252760e81148022c44
5
5
  SHA512:
6
- metadata.gz: 2eb212cb3768b60012066aaa9571e016d4ccb9ffec661560dcf7d7d20d39388313ee6b6a8ab66917d5b9334d905688795b9e50d97ff8375c95b82123f50216a3
7
- data.tar.gz: 5967f9290bb98217ea92a0fa2199af9b140ce5ace7b49894dec65f05dda5eaaa115b66c53f0cdcaa0ef5d8984c20c0418dd346515c7e69e186813a71cfaffb59
6
+ metadata.gz: 839a15a2876f6855bbe4a7efdce3d1243dcc591c6962623f809a98582e753e085ce0bb409be726ede08f0cdfd6f438add649fdaddd20ac509dcdd6dd60b992a4
7
+ data.tar.gz: 0efd8b69909220e73f8f5683c8275af8040f1e61f5a2687cf097face9fa5ce14d6d5a3d46c10cceed96b2200cc98ecc4f363f5ca2a15a5f1cb16fa3344b9bd7c
@@ -2,6 +2,7 @@ module FastImageParsing
2
2
  class Avif < ImageBase # :nodoc:
3
3
  def dimensions
4
4
  bmff = IsoBmff.new(@stream)
5
+ return nil unless bmff.width && bmff.height
5
6
  [bmff.width, bmff.height]
6
7
  end
7
8
 
@@ -13,8 +13,11 @@ module FastImageParsing
13
13
  @str = ''
14
14
  end
15
15
 
16
- # Peeking beyond the end of the input will raise
16
+ # Peeking beyond the end of the input will raise. A negative length would
17
+ # move the cursor backwards, so treat it as unparseable data.
17
18
  def peek(n)
19
+ raise FastImage::CannotParseImage if n < 0
20
+
18
21
  while @strpos + n > @str.size
19
22
  unused_str = @str[@strpos..-1]
20
23
 
@@ -38,6 +41,8 @@ module FastImageParsing
38
41
  end
39
42
 
40
43
  def skip(n)
44
+ raise FastImage::CannotParseImage if n < 0
45
+
41
46
  discarded = 0
42
47
  fetched = @str[@strpos..-1].size
43
48
  while n > fetched
@@ -2,6 +2,7 @@ module FastImageParsing
2
2
  class Heic < ImageBase # :nodoc:
3
3
  def dimensions
4
4
  bmff = IsoBmff.new(@stream)
5
+ return nil unless bmff.width && bmff.height
5
6
  [bmff.width, bmff.height]
6
7
  end
7
8
  end
@@ -27,11 +27,11 @@ module FastImageParsing
27
27
  read_boxes!
28
28
  end
29
29
 
30
- if [90, 270].include?(@rotation)
30
+ if @final_size && [90, 270].include?(@rotation)
31
31
  @final_size.reverse!
32
32
  end
33
-
34
- @width, @height = @final_size
33
+
34
+ @width, @height = @final_size if @final_size
35
35
  end
36
36
 
37
37
  private
@@ -153,8 +153,18 @@ module FastImageParsing
153
153
  def read_box_header!
154
154
  size = read_uint32!
155
155
  type = @stream.read(4)
156
- size = read_uint64! - 8 if size == 1
157
- [type, size - 8]
156
+ if size == 1
157
+ size = read_uint64!
158
+ throw :finish if size < 16
159
+ [type, size - 16]
160
+ else
161
+ # size == 0 means the box extends to end of file (ISO/IEC 14496-12 §4.2).
162
+ # size < 8 is malformed (smaller than the header itself). Either way, no
163
+ # further boxes can be parsed at this level, so stop rather than looping
164
+ # on a non-advancing skip.
165
+ throw :finish if size < 8
166
+ [type, size - 8]
167
+ end
158
168
  end
159
169
 
160
170
  def read_uint8!
@@ -6,6 +6,7 @@ module FastImageParsing
6
6
  [jxlc.width, jxlc.height]
7
7
  else
8
8
  bmff = IsoBmff.new(@stream)
9
+ return nil unless bmff.width && bmff.height
9
10
  [bmff.width, bmff.height]
10
11
  end
11
12
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class FastImage
4
- VERSION = '2.4.1'
4
+ VERSION = '2.4.3'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastimage
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.1
4
+ version: 2.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Sykes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-03-10 00:00:00.000000000 Z
11
+ date: 2026-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fakeweb-fi