mimemagic 0.3.8 → 0.3.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e2c3a9896445d8ed6f6e83bbfeedfd9df42e8d59747ada8814ee2609fe15645a
4
- data.tar.gz: 84b804a59ebd1cbbe8772403ffc3ec7a145d6f72d39240916d0e879559cd9baf
3
+ metadata.gz: 1d84538302b0c1f003f3e36f11e0e2835ca9b540a6e9a1d4a47b924fdf4776e6
4
+ data.tar.gz: 6d93e1248f0316bc5044ddd0e8d52de3578d3a75421b157a5de2e3679a091ea0
5
5
  SHA512:
6
- metadata.gz: ae357c325788a4c4d1945525a24197042513484be2733bf11be411ff909cf5e646798107f87c05b016da0b29534f94f2dee88896da0899e561d7296eb4337b16
7
- data.tar.gz: 94fbee1a133e99bd513c9c851898e5094c8b011819785c73378ecfeb50d2a0295507d761a5cce3dd6c2342e93f2e5a75128c98c76face17f708c14539c20f916
6
+ metadata.gz: 4df9042b85cb9ad4a775eb16a7b0818c7968e231c461acf03bb2d6e23aaacdb18d01949816be8f5978f963ce0285d59a3b393124c66b880b0eec5d0625642606
7
+ data.tar.gz: 52c7730c100af91b4231850ddc733b896b56db96513cc9661d984884bb19c61c46f1210959bb2608666488141d1eb54e33b610ebee9d3654d4c8f7b192ba0a00
data/CHANGELOG.md CHANGED
@@ -18,6 +18,13 @@ None
18
18
 
19
19
  None
20
20
 
21
+ ## 0.3.9 (2021-03-25)
22
+
23
+ * Resolve issues parsing the version of freedesktop.org.xml shipped with
24
+ Ubuntu Trusty.
25
+
26
+ * Make Rake a runtime dependency.
27
+
21
28
  ## 0.3.8 (2021-03-25)
22
29
 
23
30
  Relax the dependency on Nokogiri to something less specific in order
@@ -9,13 +9,13 @@ def locate_mime_database
9
9
  "/usr/share/mime/packages/freedesktop.org.xml"
10
10
  ].compact
11
11
  path = possible_paths.find { |candidate| File.exist?(candidate) }
12
-
12
+
13
13
  return path unless path.nil?
14
- raise(<<~ERROR)
14
+ raise(<<-ERROR.gsub(/^ {3}/, ""))
15
15
  Could not find MIME type database in the following locations: #{possible_paths}
16
-
17
- Ensure you have either installed the shared-mime-types package for your distribution, or
18
- obtain a version of freedesktop.org.xml and set FREEDESKTOP_MIME_TYPES_PATH to the location
16
+
17
+ Ensure you have either installed the shared-mime-info package for your distribution, or
18
+ obtain a version of freedesktop.org.xml and set FREEDESKTOP_MIME_TYPES_PATH to the location
19
19
  of that file.
20
20
  ERROR
21
21
  end
@@ -30,4 +30,4 @@ task :default do
30
30
  end
31
31
  })
32
32
  end
33
- end
33
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+ # Extra magic
3
+
4
+ [['application/vnd.openxmlformats-officedocument.presentationml.presentation', [[0, "PK\003\004", [[0..5000, '[Content_Types].xml', [[0..5000, 'ppt/']]]]]]],
5
+ ['application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', [[0, "PK\003\004", [[0..5000, '[Content_Types].xml', [[0..5000, 'xl/']]]]]]],
6
+ ['application/vnd.openxmlformats-officedocument.wordprocessingml.document', [[0, "PK\003\004", [[0..5000, '[Content_Types].xml', [[0..5000, 'word/']]]]]]]].each do |magic|
7
+ MimeMagic.add(magic[0], magic: magic[1])
8
+ end
@@ -26,7 +26,16 @@ class MimeMagic
26
26
  offset = offset.size == 2 ? offset[0]..offset[1] : offset[0]
27
27
  case type
28
28
  when 'string'
29
- value.gsub!(/\\(x[\dA-Fa-f]{1,2}|0\d{1,3}|\d{1,3}|.)/) { eval("\"\\#{$1}\"") }
29
+ # This *one* pattern match, in the entirety of fd.o's mime types blows up the parser
30
+ # because of the escape character \c, so right here we have a hideous hack to
31
+ # accommodate that.
32
+ if value == '\chapter'
33
+ '\chapter'
34
+ else
35
+ value.gsub!(/\\(x[\dA-Fa-f]{1,2}|0\d{1,3}|\d{1,3}|.)/) {
36
+ eval("\"\\#{$1}\"")
37
+ }
38
+ end
30
39
  when 'big16'
31
40
  value = str2int(value)
32
41
  value = ((value >> 8).chr + (value & 0xFF).chr)
@@ -1,5 +1,5 @@
1
1
  class MimeMagic
2
2
  # MimeMagic version string
3
3
  # @api public
4
- VERSION = '0.3.8'
4
+ VERSION = '0.3.9'
5
5
  end
data/mimemagic.gemspec CHANGED
@@ -20,9 +20,9 @@ Gem::Specification.new do |s|
20
20
  s.license = 'MIT'
21
21
 
22
22
  s.add_dependency('nokogiri', '~> 1')
23
+ s.add_dependency('rake')
23
24
 
24
25
  s.add_development_dependency('minitest', '~> 5.14')
25
- s.add_development_dependency('rake', '~> 13.0')
26
26
 
27
27
  if s.respond_to?(:metadata)
28
28
  s.metadata['changelog_uri'] = "https://github.com/mimemagicrb/mimemagic/blob/master/CHANGELOG.md"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mimemagic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.8
4
+ version: 0.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Mendler
@@ -26,33 +26,33 @@ dependencies:
26
26
  - !ruby/object:Gem::Version
27
27
  version: '1'
28
28
  - !ruby/object:Gem::Dependency
29
- name: minitest
29
+ name: rake
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - "~>"
32
+ - - ">="
33
33
  - !ruby/object:Gem::Version
34
- version: '5.14'
35
- type: :development
34
+ version: '0'
35
+ type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - "~>"
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
- version: '5.14'
41
+ version: '0'
42
42
  - !ruby/object:Gem::Dependency
43
- name: rake
43
+ name: minitest
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: '13.0'
48
+ version: '5.14'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: '13.0'
55
+ version: '5.14'
56
56
  description: Fast mime detection by extension or content in pure ruby (Uses freedesktop.org.xml
57
57
  shared-mime-info database)
58
58
  email: