format_parser 1.4.0 → 1.4.1
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 +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/format_parser/version.rb +1 -1
- data/lib/parsers/webp_parser.rb +13 -6
- data/spec/parsers/webp_parser_spec.rb +15 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6402f116eddca928e4807f76d4631f052a841c360137833310900b9604107997
|
4
|
+
data.tar.gz: 62e2a34f739d912f850e1e732c3e9cc154eadcaff5c76cc0f56fc163298e9192
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9385682da9e3a86f67e25cf3491c90f8993a4073a9378f33d20e470f5917dea9afe913c29c16f17412e5f46fb226b8016c51a18327eee74b5f624e304d227c83
|
7
|
+
data.tar.gz: 2aa680436faa13496921e6134b3b3c341bd0e0b21c1a2a8656e3102165bb6f5bdec941790797861720f840283a171dc9501ae572f4048c8fbe76393badb8bdea
|
data/CHANGELOG.md
CHANGED
data/lib/parsers/webp_parser.rb
CHANGED
@@ -129,7 +129,7 @@ class FormatParser::WebpParser
|
|
129
129
|
# Try to read the next chunk header, and break the loop if we've reached EOF.
|
130
130
|
begin
|
131
131
|
fourcc, chunk_size = safe_read(@buf, 8).unpack('A4V')
|
132
|
-
rescue InvalidRead
|
132
|
+
rescue FormatParser::IOUtils::InvalidRead
|
133
133
|
break
|
134
134
|
end
|
135
135
|
|
@@ -138,11 +138,18 @@ class FormatParser::WebpParser
|
|
138
138
|
|
139
139
|
case fourcc
|
140
140
|
when 'EXIF'
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
141
|
+
chunk_pos = @buf.pos
|
142
|
+
begin
|
143
|
+
exif = exif_from_tiff_io(StringIO.new(safe_read(@buf, chunk_size)))
|
144
|
+
# We use ||= here as one Exif chunk at most should be present, even though it is possible for there to be more.
|
145
|
+
intrinsics[:exif] ||= exif
|
146
|
+
image.height_px, image.width_px = image.width_px, image.height_px if exif&.rotated?
|
147
|
+
image.orientation = exif&.orientation_sym
|
148
|
+
rescue EXIFR::MalformedTIFF
|
149
|
+
# Exif data was malformed and could not be parsed. Need to ensure that buffer is pointing at the next chunk.
|
150
|
+
@buf.seek(chunk_pos + chunk_size)
|
151
|
+
next
|
152
|
+
end
|
146
153
|
when 'XMP'
|
147
154
|
# We use ||= here as one XMP chunk at most should be present, even though it is possible for there to be more.
|
148
155
|
intrinsics[:xmp] ||= safe_read(@buf, chunk_size)
|
@@ -118,4 +118,19 @@ describe FormatParser::WebpParser do
|
|
118
118
|
expect(result.orientation).to be_nil
|
119
119
|
expect(result.width_px).to eq(211)
|
120
120
|
end
|
121
|
+
|
122
|
+
it 'successfully skips malformed Exif chunks' do
|
123
|
+
result = subject.call(File.open(fixtures_dir + 'WEBP/extended-malformed-exif.webp', 'rb'))
|
124
|
+
expect(result).not_to be_nil
|
125
|
+
expect(result.content_type).to eq('image/webp')
|
126
|
+
expect(result.format).to eq(:webp)
|
127
|
+
expect(result.has_multiple_frames).to eq(false)
|
128
|
+
expect(result.has_transparency).to eq(false)
|
129
|
+
expect(result.height_px).to eq(181)
|
130
|
+
expect(result.intrinsics).not_to be_nil
|
131
|
+
expect(result.intrinsics[:exif]).to be_nil
|
132
|
+
expect(result.intrinsics[:xmp]).not_to be_nil
|
133
|
+
expect(result.orientation).to be_nil
|
134
|
+
expect(result.width_px).to eq(65)
|
135
|
+
end
|
121
136
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: format_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Noah Berman
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-07-
|
12
|
+
date: 2022-07-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ks
|