format_parser 0.25.3 → 0.25.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -2
- data/CHANGELOG.md +4 -0
- data/lib/format_parser/version.rb +1 -1
- data/lib/parsers/mp3_parser.rb +7 -0
- data/lib/parsers/tiff_parser.rb +2 -1
- data/spec/parsers/mp3_parser_spec.rb +8 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 379af5330f9b9521b278e5fe54821398ea2a5a58d4ac9881bcc5f30021446c2a
|
4
|
+
data.tar.gz: 71da3110186c0c8fce731fc2adb05fbcbcc829ab9c6fe67b4934dc8d69fa093c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a9a99547baa58e3e693c8e24cc84af0d1e6598403dbed9473b885531e7c067b51c5aac4cc411ddc3f7d114b7987b470eb81554422553e6b346fc42b98a50789
|
7
|
+
data.tar.gz: 851b0c4fad434140e641077c01e6d46f463c8aab7b85d35a85ba0729c2913bd978a35e7ab0608d4cb8d5e2e2f13761a00078b98948290c3b3203953a9cba7c03
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/lib/parsers/mp3_parser.rb
CHANGED
@@ -29,6 +29,10 @@ class FormatParser::MP3Parser
|
|
29
29
|
ZIP_LOCAL_ENTRY_SIGNATURE = "PK\x03\x04\x14\x00".b
|
30
30
|
PNG_HEADER_BYTES = [137, 80, 78, 71, 13, 10, 26, 10].pack('C*')
|
31
31
|
|
32
|
+
MAGIC_LE = [0x49, 0x49, 0x2A, 0x0].pack('C4')
|
33
|
+
MAGIC_BE = [0x4D, 0x4D, 0x0, 0x2A].pack('C4')
|
34
|
+
TIFF_HEADER_BYTES = [MAGIC_LE, MAGIC_BE]
|
35
|
+
|
32
36
|
# Wraps the Tag object returned by ID3Tag in such
|
33
37
|
# a way that a usable JSON representation gets
|
34
38
|
# returned
|
@@ -68,6 +72,9 @@ class FormatParser::MP3Parser
|
|
68
72
|
return if header.start_with?(ZIP_LOCAL_ENTRY_SIGNATURE)
|
69
73
|
return if header.start_with?(PNG_HEADER_BYTES)
|
70
74
|
|
75
|
+
io.seek(0)
|
76
|
+
return if TIFF_HEADER_BYTES.include?(safe_read(io, 4))
|
77
|
+
|
71
78
|
# Read all the ID3 tags (or at least attempt to)
|
72
79
|
io.seek(0)
|
73
80
|
id3v1 = ID3Extraction.attempt_id3_v1_extraction(io)
|
data/lib/parsers/tiff_parser.rb
CHANGED
@@ -4,6 +4,7 @@ class FormatParser::TIFFParser
|
|
4
4
|
|
5
5
|
MAGIC_LE = [0x49, 0x49, 0x2A, 0x0].pack('C4')
|
6
6
|
MAGIC_BE = [0x4D, 0x4D, 0x0, 0x2A].pack('C4')
|
7
|
+
HEADER_BYTES = [MAGIC_LE, MAGIC_BE]
|
7
8
|
|
8
9
|
def likely_match?(filename)
|
9
10
|
filename =~ /\.tiff?$/i
|
@@ -12,7 +13,7 @@ class FormatParser::TIFFParser
|
|
12
13
|
def call(io)
|
13
14
|
io = FormatParser::IOConstraint.new(io)
|
14
15
|
|
15
|
-
return unless
|
16
|
+
return unless HEADER_BYTES.include?(safe_read(io, 4))
|
16
17
|
io.seek(io.pos + 2) # Skip over the offset of the IFD, EXIFR will re-read it anyway
|
17
18
|
return if cr2?(io)
|
18
19
|
|
@@ -205,4 +205,12 @@ describe FormatParser::MP3Parser do
|
|
205
205
|
).to eq([ID3Tag::Tag])
|
206
206
|
end
|
207
207
|
end
|
208
|
+
|
209
|
+
it 'does not recognize TIFF files as MP3' do
|
210
|
+
fpath = fixtures_dir + '/TIFF/test2.tif'
|
211
|
+
|
212
|
+
parsed = subject.call(File.open(fpath, 'rb'))
|
213
|
+
|
214
|
+
expect(parsed).to be_nil
|
215
|
+
end
|
208
216
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: format_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.25.
|
4
|
+
version: 0.25.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Noah Berman
|
8
8
|
- Julik Tarkhanov
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-12-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ks
|
@@ -277,7 +277,7 @@ licenses:
|
|
277
277
|
- MIT (Hippocratic)
|
278
278
|
metadata:
|
279
279
|
allowed_push_host: https://rubygems.org
|
280
|
-
post_install_message:
|
280
|
+
post_install_message:
|
281
281
|
rdoc_options: []
|
282
282
|
require_paths:
|
283
283
|
- lib
|
@@ -292,8 +292,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
292
292
|
- !ruby/object:Gem::Version
|
293
293
|
version: '0'
|
294
294
|
requirements: []
|
295
|
-
rubygems_version: 3.1.
|
296
|
-
signing_key:
|
295
|
+
rubygems_version: 3.1.4
|
296
|
+
signing_key:
|
297
297
|
specification_version: 4
|
298
298
|
summary: A library for efficient parsing of file metadata
|
299
299
|
test_files: []
|