format_parser 0.13.0 → 0.13.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/jpeg_parser.rb +0 -11
- data/lib/parsers/zip_parser/file_reader.rb +0 -19
- data/spec/parsers/zip_parser_spec.rb +0 -14
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3c1744492b66a28cf9ff258a894c28f74552eb560794e74bb2ab9c06801f0be
|
4
|
+
data.tar.gz: 7f92fb35cd4b18992879b6a37799c479452f83f67e5535bc92711a26af0bcc02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b45536df47aaf92fd28c4d32bc5ce67bf66cda6d1079f1212e4a7f21fa90b998938adb0e619251a30a65637e04f6de372a6bb545cc856bd7f3fcf36a82a87caa
|
7
|
+
data.tar.gz: f7604ed45d27c6316d2dcf78df2dae6ec6bebe405cc20639e0b5364f1c0018c4b3f9e621ebeb93d198f8472f293f436a40958312e1d2d1c9b0cdb8530a05b159
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
## 0.13.1
|
2
|
+
* Avoid ZIP checks in the JPEG parser which are no longer necessary
|
3
|
+
|
1
4
|
## 0.13.0
|
2
5
|
* Replace the homegrown ID3 parser with [id3tag](https://github.com/krists/id3tag) - this introduces id3tag
|
3
6
|
as a dependency in addition to `exifr`, but the gains are substantial.
|
data/lib/parsers/jpeg_parser.rb
CHANGED
@@ -42,12 +42,6 @@ class FormatParser::JPEGParser
|
|
42
42
|
|
43
43
|
markers_start_at = @buf.pos
|
44
44
|
|
45
|
-
# Keynote files start with a series of _perfectly_ valid
|
46
|
-
# JPEG markers, probably for icon previews or QuickLook.
|
47
|
-
# We have to detect those and reject them earlier. We can
|
48
|
-
# make use of our magic ZIP reader to get there.
|
49
|
-
return if probably_keynote_zip?
|
50
|
-
|
51
45
|
@buf.seek(markers_start_at)
|
52
46
|
|
53
47
|
while marker = read_next_marker
|
@@ -165,10 +159,5 @@ class FormatParser::JPEGParser
|
|
165
159
|
safe_skip(@buf, length)
|
166
160
|
end
|
167
161
|
|
168
|
-
def probably_keynote_zip?
|
169
|
-
reader = FormatParser::ZIPParser::FileReader.new
|
170
|
-
reader.zip?(@buf)
|
171
|
-
end
|
172
|
-
|
173
162
|
FormatParser.register_parser self, natures: :image, formats: :jpg
|
174
163
|
end
|
@@ -195,25 +195,6 @@ class FormatParser::ZIPParser::FileReader
|
|
195
195
|
entries
|
196
196
|
end
|
197
197
|
|
198
|
-
# Tells whether the given IO is likely to be a ZIP file without
|
199
|
-
# performing too many detailed reads
|
200
|
-
#
|
201
|
-
# @param io[#tell, #seek, #read, #size] an IO-ish object
|
202
|
-
# @return [Boolean]
|
203
|
-
def zip?(io)
|
204
|
-
zip_file_size = io.size
|
205
|
-
eocd_offset = get_eocd_offset(io, zip_file_size)
|
206
|
-
zip64_end_of_cdir_location = get_zip64_eocd_location(io, eocd_offset)
|
207
|
-
if zip64_end_of_cdir_location
|
208
|
-
num_files_and_central_directory_offset_zip64(io, zip64_end_of_cdir_location)
|
209
|
-
else
|
210
|
-
num_files_and_central_directory_offset(io, eocd_offset)
|
211
|
-
end
|
212
|
-
true
|
213
|
-
rescue Error
|
214
|
-
false
|
215
|
-
end
|
216
|
-
|
217
198
|
private
|
218
199
|
|
219
200
|
def skip_ahead_2(io)
|
@@ -98,18 +98,4 @@ describe FormatParser::ZIPParser do
|
|
98
98
|
expect(first_entry.filename).to eq('Li��nia Extreme//')
|
99
99
|
expect(first_entry.type).to eq(:directory)
|
100
100
|
end
|
101
|
-
|
102
|
-
describe 'FileReader#zip?' do
|
103
|
-
it 'correctly detects all the ZIP files as such' do
|
104
|
-
reader = described_class::FileReader.new
|
105
|
-
Dir.glob(fixtures_dir + '/ZIP/*.zip').each do |path|
|
106
|
-
expect(reader).to be_zip(File.open(path, 'rb'))
|
107
|
-
end
|
108
|
-
|
109
|
-
4.times do
|
110
|
-
blob = Random.new.bytes(1024)
|
111
|
-
expect(reader).not_to be_zip(StringIO.new(blob))
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
101
|
end
|