mime-types 3.5.2 → 3.7.0

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.
data/CONTRIBUTORS.md ADDED
@@ -0,0 +1,52 @@
1
+ # Contributors
2
+
3
+ - Austin Ziegler created mime-types.
4
+
5
+ Thanks to everyone else who has contributed to mime-types over the years:
6
+
7
+ - Aaron Patterson
8
+ - Aggelos Avgerinos
9
+ - Al Snow
10
+ - Alex Vondrak
11
+ - Andre Pankratz
12
+ - Andy Brody
13
+ - Arnaud Meuret
14
+ - Brandon Galbraith
15
+ - Burke Libbey
16
+ - Chris Gat
17
+ - Daniel Watkins
18
+ - David Genord
19
+ - Dillon Welch
20
+ - Edward Betts
21
+ - Eric Marden
22
+ - Garret Alfert
23
+ - Godfrey Chan
24
+ - Greg Brockman
25
+ - Hans de Graaff
26
+ - Henrik Hodne
27
+ - Igor Victor
28
+ - Janko Marohnić
29
+ - Jean Boussier
30
+ - Jeremy Evans
31
+ - Juanito Fatas
32
+ - Jun Aruga
33
+ - Keerthi Siva
34
+ - Ken Ip
35
+ - Kevin Menard
36
+ - Koichi ITO
37
+ - Łukasz Śliwa
38
+ - Martin d'Allens
39
+ - Masato Nakamura
40
+ - Mauricio Linhares
41
+ - Nana Kugayama
42
+ - Nicholas La Roux
43
+ - Nicolas Leger
44
+ - nycvotes-dev
45
+ - Olle Jonsson
46
+ - Postmodern
47
+ - Richard Hirner
48
+ - Richard Hurt
49
+ - Richard Schneeman
50
+ - Robb Shecter
51
+ - Tibor Szolár
52
+ - Todd Carrico
@@ -1,6 +1,6 @@
1
1
  # Licence
2
2
 
3
- - Copyright 2003–2019 Austin Ziegler and contributors.
3
+ - Copyright 2003-2025 Austin Ziegler and contributors.
4
4
 
5
5
  The software in this repository is made available under the MIT license.
6
6
 
@@ -9,17 +9,16 @@ The software in this repository is made available under the MIT license.
9
9
  Permission is hereby granted, free of charge, to any person obtaining a copy of
10
10
  this software and associated documentation files (the "Software"), to deal in
11
11
  the Software without restriction, including without limitation the rights to
12
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
13
- of the Software, and to permit persons to whom the Software is furnished to do
14
- so, subject to the following conditions:
12
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
13
+ the Software, and to permit persons to whom the Software is furnished to do so,
14
+ subject to the following conditions:
15
15
 
16
16
  The above copyright notice and this permission notice shall be included in all
17
17
  copies or substantial portions of the Software.
18
18
 
19
19
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
- SOFTWARE.
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
21
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
22
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
23
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest.txt CHANGED
@@ -1,11 +1,12 @@
1
- .standard.yml
2
- Code-of-Conduct.md
3
- Contributing.md
4
- History.md
5
- Licence.md
1
+ CHANGELOG.md
2
+ CODE_OF_CONDUCT.md
3
+ CONTRIBUTING.md
4
+ CONTRIBUTORS.md
5
+ LICENCE.md
6
6
  Manifest.txt
7
- README.rdoc
7
+ README.md
8
8
  Rakefile
9
+ SECURITY.md
9
10
  lib/mime-types.rb
10
11
  lib/mime/type.rb
11
12
  lib/mime/type/columnar.rb
@@ -19,6 +20,7 @@ lib/mime/types/full.rb
19
20
  lib/mime/types/loader.rb
20
21
  lib/mime/types/logger.rb
21
22
  lib/mime/types/registry.rb
23
+ lib/mime/types/version.rb
22
24
  test/bad-fixtures/malformed
23
25
  test/fixture/json.json
24
26
  test/fixture/old-data
data/README.md ADDED
@@ -0,0 +1,200 @@
1
+ # mime-types for Ruby
2
+
3
+ - home :: https://github.com/mime-types/ruby-mime-types/
4
+ - issues :: https://github.com/mime-types/ruby-mime-types/issues
5
+ - code :: https://github.com/mime-types/ruby-mime-types/
6
+ - rdoc :: http://rdoc.info/gems/mime-types/
7
+ - changelog ::
8
+ https://github.com/mime-types/ruby-mime-types/blob/main/CHANGELOG.md
9
+ - continuous integration :: [![Build Status][ci-badge]][ci-workflow]
10
+ - test coverage :: [![Coverage][coveralls-badge]][coveralls]
11
+
12
+ ## Description
13
+
14
+ The mime-types library provides a library and registry for information about
15
+ MIME content type definitions. It can be used to determine defined filename
16
+ extensions for MIME types, or to use filename extensions to look up the likely
17
+ MIME type definitions.
18
+
19
+ Version 3.0 is a major release that requires Ruby 2.0 compatibility and removes
20
+ deprecated functions. The columnar registry format introduced in 2.6 has been
21
+ made the primary format; the registry data has been extracted from this library
22
+ and put into [mime-types-data][data]. Additionally, mime-types is now licensed
23
+ exclusively under the MIT licence and there is a code of conduct in effect.
24
+ There are a number of other smaller changes described in the History file.
25
+
26
+ ### About MIME Media Types
27
+
28
+ MIME content types are used in MIME-compliant communications, as in e-mail or
29
+ HTTP traffic, to indicate the type of content which is transmitted. The
30
+ mime-types library provides the ability for detailed information about MIME
31
+ entities (provided as an enumerable collection of MIME::Type objects) to be
32
+ determined and used. There are many types defined by RFCs and vendors, so the
33
+ list is long but by definition incomplete; don't hesitate to add additional type
34
+ definitions. MIME type definitions found in mime-types are from RFCs, W3C
35
+ recommendations, the [IANA Media Types registry][registry], and user
36
+ contributions. It conforms to RFCs 2045 and 2231.
37
+
38
+ ### mime-types 3.x
39
+
40
+ Users are encouraged to upgrade to mime-types 3.x as soon as is practical.
41
+ mime-types 3.x requires Ruby 2.0 compatibility and a simpler licensing scheme.
42
+
43
+ ## Synopsis
44
+
45
+ MIME types are used in MIME entities, as in email or HTTP traffic. It is useful
46
+ at times to have information available about MIME types (or, inversely, about
47
+ files). A MIME::Type stores the known information about one MIME type.
48
+
49
+ ```ruby
50
+ require 'mime/types'
51
+
52
+ plaintext = MIME::Types['text/plain'] # => [ text/plain ]
53
+ text = plaintext.first
54
+ puts text.media_type # => 'text'
55
+ puts text.sub_type # => 'plain'
56
+
57
+ puts text.extensions.join(' ') # => 'txt asc c cc h hh cpp hpp dat hlp'
58
+ puts text.preferred_extension # => 'txt'
59
+ puts text.friendly # => 'Text Document'
60
+ puts text.i18n_key # => 'text.plain'
61
+
62
+ puts text.encoding # => quoted-printable
63
+ puts text.default_encoding # => quoted-printable
64
+ puts text.binary? # => false
65
+ puts text.ascii? # => true
66
+ puts text.obsolete? # => false
67
+ puts text.registered? # => true
68
+ puts text.provisional? # => false
69
+ puts text.complete? # => true
70
+
71
+ puts text # => 'text/plain'
72
+
73
+ puts text == 'text/plain' # => true
74
+ puts 'text/plain' == text # => true
75
+ puts text == 'text/x-plain' # => false
76
+ puts 'text/x-plain' == text # => false
77
+
78
+ puts MIME::Type.simplified('x-appl/x-zip') # => 'x-appl/x-zip'
79
+ puts MIME::Type.i18n_key('x-appl/x-zip') # => 'x-appl.x-zip'
80
+
81
+ puts text.like?('text/x-plain') # => true
82
+ puts text.like?(MIME::Type.new('x-text/x-plain')) # => true
83
+
84
+ puts text.xrefs.inspect # => { "rfc" => [ "rfc2046", "rfc3676", "rfc5147" ] }
85
+ puts text.xref_urls # => [ "http://www.iana.org/go/rfc2046",
86
+ # "http://www.iana.org/go/rfc3676",
87
+ # "http://www.iana.org/go/rfc5147" ]
88
+
89
+ xtext = MIME::Type.new('x-text/x-plain')
90
+ puts xtext.media_type # => 'text'
91
+ puts xtext.raw_media_type # => 'x-text'
92
+ puts xtext.sub_type # => 'plain'
93
+ puts xtext.raw_sub_type # => 'x-plain'
94
+ puts xtext.complete? # => false
95
+
96
+ puts MIME::Types.any? { |type| type.content_type == 'text/plain' } # => true
97
+ puts MIME::Types.all?(&:registered?) # => false
98
+
99
+ # Various string representations of MIME types
100
+ qcelp = MIME::Types['audio/QCELP'].first # => audio/QCELP
101
+ puts qcelp.content_type # => 'audio/QCELP'
102
+ puts qcelp.simplified # => 'audio/qcelp'
103
+
104
+ xwingz = MIME::Types['application/x-Wingz'].first # => application/x-Wingz
105
+ puts xwingz.content_type # => 'application/x-Wingz'
106
+ puts xwingz.simplified # => 'application/x-wingz'
107
+ ```
108
+
109
+ ### Columnar Store
110
+
111
+ mime-types uses as its primary registry storage format a columnar storage format
112
+ reducing the default memory footprint. This is done by selectively loading the
113
+ data on a per-attribute basis. When the registry is first loaded from the
114
+ columnar store, only the canonical MIME content type and known extensions and
115
+ the MIME type will be connected to its loading registry. When other data about
116
+ the type is required (including `preferred_extension`, `obsolete?`, and
117
+ `registered?`) that data is loaded from its own column file for all types in the
118
+ registry.
119
+
120
+ The load of any column data is performed with a Mutex to ensure that types are
121
+ updated safely in a multithreaded environment. Benchmarks show that while
122
+ columnar data loading is slower than the JSON store, it cuts the memory use by a
123
+ third over the JSON store.
124
+
125
+ If you prefer to load all the data at once, this can be specified in your
126
+ application Gemfile as:
127
+
128
+ ```ruby
129
+ gem 'mime-types', require: 'mime/types/full'
130
+ ```
131
+
132
+ Projects that do not use Bundler should `require` the same:
133
+
134
+ ```ruby
135
+ require 'mime/types/full'
136
+ ```
137
+
138
+ Libraries that use mime-types are discouraged from choosing the JSON store.
139
+
140
+ For applications and clients that used mime-types 2.6 when the columnar store
141
+ was introduced, the require used previously will still work through at least
142
+ [version 4][pull-96-comment] and possibly beyond; it is effectively an empty
143
+ operation. You are recommended to change your Gemfile as soon as is practical.
144
+
145
+ ```ruby
146
+ require 'mime/types/columnar'
147
+ ```
148
+
149
+ Note that MIME::Type::Columnar and MIME::Types::Columnar are considered private
150
+ variant implementations of MIME::Type and MIME::Types and the specific
151
+ implementation should not be relied upon by consumers of the mime-types library.
152
+ Instead, depend on the public implementations (MIME::Type and MIME::Types) only.
153
+
154
+ ### Cached Storage
155
+
156
+ mime-types supports a cache of MIME types using `Marshal.dump`. The cache is
157
+ invalidated for each version of the mime-types-data gem so that data version
158
+ 3.2015.1201 will not be reused with data version 3.2016.0101. If the environment
159
+ variable `RUBY_MIME_TYPES_CACHE` is set to a cache file, mime-types will attempt
160
+ to load the MIME type registry from the cache file. If it cannot, it will load
161
+ the types normally and then saves the registry to the cache file.
162
+
163
+ The caching works with both full stores and columnar stores. Only the data that
164
+ has been loaded prior to saving the cache will be stored.
165
+
166
+ ## mime-types Modified Semantic Versioning
167
+
168
+ The mime-types library has one version number, but this single version number
169
+ tracks both API changes and registry data changes; this is not wholly compatible
170
+ with all aspects of [Semantic Versioning][semver]; removing a MIME type from the
171
+ registry _could_ be considered a breaking change under some interpretations of
172
+ semantic versioning (as lookups for that particular type would no longer work by
173
+ default).
174
+
175
+ mime-types itself uses a modified semantic versioning scheme. Given the version
176
+ `MAJOR.MINOR`:
177
+
178
+ 1. If an incompatible API (code) change is made, the `MAJOR` version will be
179
+ incremented and both `MINOR` and `PATCH` will be set to zero. Major version
180
+ updates will also generally break Ruby version compatibility guarantees.
181
+
182
+ 2. If an API (code) feature is added that does not break compatibility, the
183
+ `MINOR` version will be incremented and `PATCH` will be set to zero.
184
+
185
+ 3. If there is a bug fix to a feature added in the most recent `MAJOR.MINOR`
186
+ release, the `PATCH` value will be incremented.
187
+
188
+ In practical terms, there will be fewer releases of mime-types focussing on
189
+ features because of the existence of the [mime-types-data][data] gem, and if
190
+ features are marked deprecated in the course of mime-types 3.x, they will not be
191
+ removed until mime-types 4.x or possibly later.
192
+
193
+ [pull-96-comment]: https://github.com/mime-types/ruby-mime-types/pull/96#issuecomment-100725400
194
+ [semver]: https://semver.org
195
+ [data]: https://github.com/mime-types/mime-types-data
196
+ [ci-badge]: https://github.com/mime-types/ruby-mime-types/actions/workflows/ci.yml/badge.svg
197
+ [ci-workflow]: https://github.com/mime-types/ruby-mime-types/actions/workflows/ci.yml
198
+ [coveralls-badge]: https://coveralls.io/repos/mime-types/ruby-mime-types/badge.svg?branch=main&service=github
199
+ [coveralls]: https://coveralls.io/github/mime-types/ruby-mime-types?branch=main
200
+ [registry]: https://www.iana.org/assignments/media-types/media-types.xhtml
data/Rakefile CHANGED
@@ -1,41 +1,74 @@
1
1
  require "rubygems"
2
2
  require "hoe"
3
3
  require "rake/clean"
4
+ require "minitest"
5
+ require "minitest/test_task"
4
6
 
5
- Hoe.plugin :cov
6
- Hoe.plugin :doofus
7
- Hoe.plugin :gemspec2
8
- Hoe.plugin :git2
9
- Hoe.plugin :minitest
7
+ Hoe.plugin :halostatue
10
8
  Hoe.plugin :rubygems
11
9
 
10
+ Hoe.plugins.delete :debug
11
+ Hoe.plugins.delete :newb
12
+ Hoe.plugins.delete :publish
13
+ Hoe.plugins.delete :signing
14
+ Hoe.plugins.delete :test
15
+
12
16
  spec = Hoe.spec "mime-types" do
13
17
  developer("Austin Ziegler", "halostatue@gmail.com")
14
18
 
15
- self.history_file = "History.md"
16
- self.readme_file = "README.rdoc"
17
-
18
- license "MIT"
19
+ self.trusted_release = ENV["rubygems_release_gem"] == "true"
19
20
 
20
21
  require_ruby_version ">= 2.0"
21
22
 
22
- spec_extras[:metadata] = ->(val) { val["rubygems_mfa_required"] = "true" }
23
+ license "MIT"
24
+
25
+ spec_extras[:metadata] = ->(val) {
26
+ val.merge!({"rubygems_mfa_required" => "true"})
27
+ }
23
28
 
24
- extra_deps << ["mime-types-data", "~> 3.2015"]
29
+ extra_deps << ["mime-types-data", "~> 3.2025", ">= 3.2025.0507"]
30
+ extra_deps << ["logger", ">= 0"]
25
31
 
26
- extra_dev_deps << ["hoe", ">= 3.0", "< 5"]
27
- extra_dev_deps << ["hoe-doofus", "~> 1.0"]
28
- extra_dev_deps << ["hoe-gemspec2", "~> 1.1"]
29
- extra_dev_deps << ["hoe-git2", "~> 1.7"]
32
+ extra_dev_deps << ["hoe", "~> 4.0"]
33
+ extra_dev_deps << ["hoe-halostatue", "~> 2.0"]
30
34
  extra_dev_deps << ["hoe-rubygems", "~> 1.0"]
31
35
  extra_dev_deps << ["minitest", "~> 5.0"]
32
36
  extra_dev_deps << ["minitest-autotest", "~> 1.0"]
33
37
  extra_dev_deps << ["minitest-focus", "~> 1.0"]
34
38
  extra_dev_deps << ["minitest-hooks", "~> 1.4"]
35
- extra_dev_deps << ["rake", ">= 10.0", "< 14.0"]
39
+ extra_dev_deps << ["rake", ">= 10.0", "< 14"]
40
+ extra_dev_deps << ["rdoc", ">= 0.0"]
36
41
  extra_dev_deps << ["standard", "~> 1.0"]
37
42
  end
38
43
 
44
+ Minitest::TestTask.create :test
45
+ Minitest::TestTask.create :coverage do |t|
46
+ formatters = <<-RUBY.split($/).join(" ")
47
+ SimpleCov::Formatter::MultiFormatter.new([
48
+ SimpleCov::Formatter::HTMLFormatter,
49
+ SimpleCov::Formatter::LcovFormatter,
50
+ SimpleCov::Formatter::SimpleFormatter
51
+ ])
52
+ RUBY
53
+ t.test_prelude = <<-RUBY.split($/).join("; ")
54
+ require "simplecov"
55
+ require "simplecov-lcov"
56
+
57
+ SimpleCov::Formatter::LcovFormatter.config do |config|
58
+ config.report_with_single_file = true
59
+ config.lcov_file_name = "lcov.info"
60
+ end
61
+
62
+ SimpleCov.start "test_frameworks" do
63
+ enable_coverage :branch
64
+ primary_coverage :branch
65
+ formatter #{formatters}
66
+ end
67
+ RUBY
68
+ end
69
+
70
+ task default: :test
71
+
39
72
  namespace :benchmark do
40
73
  task :support do
41
74
  %w[lib support].each { |path|
@@ -52,39 +85,9 @@ namespace :benchmark do
52
85
  )
53
86
  end
54
87
 
55
- desc "Allocation counts"
56
- task :allocations, [:top_x, :mime_types_only] => "benchmark:support" do |_, args|
57
- require "benchmarks/load_allocations"
58
- Benchmarks::LoadAllocations.report(
59
- top_x: args.top_x,
60
- mime_types_only: args.mime_types_only
61
- )
62
- end
63
-
64
- desc "Columnar allocation counts"
65
- task "allocations:columnar", [:top_x, :mime_types_only] => "benchmark:support" do |_, args|
66
- require "benchmarks/load_allocations"
67
- Benchmarks::LoadAllocations.report(
68
- columnar: true,
69
- top_x: args.top_x,
70
- mime_types_only: args.mime_types_only
71
- )
72
- end
73
-
74
- desc "Columnar allocation counts (full load)"
75
- task "allocations:columnar:full", [:top_x, :mime_types_only] => "benchmark:support" do |_, args|
76
- require "benchmarks/load_allocations"
77
- Benchmarks::LoadAllocations.report(
78
- columnar: true,
79
- top_x: args.top_x,
80
- mime_types_only: args.mime_types_only,
81
- full: true
82
- )
83
- end
84
-
85
88
  desc "Memory profiler"
86
89
  task :memory, [:top_x, :mime_types_only] => "benchmark:support" do |_, args|
87
- require "benchmarks/memory_profiler"
90
+ require "benchmarks/profile_memory"
88
91
  Benchmarks::ProfileMemory.report(
89
92
  mime_types_only: args.mime_types_only,
90
93
  top_x: args.top_x
@@ -93,7 +96,7 @@ namespace :benchmark do
93
96
 
94
97
  desc "Columnar memory profiler"
95
98
  task "memory:columnar", [:top_x, :mime_types_only] => "benchmark:support" do |_, args|
96
- require "benchmarks/memory_profiler"
99
+ require "benchmarks/profile_memory"
97
100
  Benchmarks::ProfileMemory.report(
98
101
  columnar: true,
99
102
  mime_types_only: args.mime_types_only,
@@ -103,7 +106,7 @@ namespace :benchmark do
103
106
 
104
107
  desc "Columnar allocation counts (full load)"
105
108
  task "memory:columnar:full", [:top_x, :mime_types_only] => "benchmark:support" do |_, args|
106
- require "benchmarks/memory_profiler"
109
+ require "benchmarks/profile_memory"
107
110
  Benchmarks::ProfileMemory.report(
108
111
  columnar: true,
109
112
  full: true,
@@ -132,53 +135,19 @@ namespace :benchmark do
132
135
  end
133
136
 
134
137
  namespace :profile do
135
- directory "tmp/profile"
136
-
137
- CLEAN.add "tmp"
138
-
139
- def ruby_prof(script)
140
- require "pathname"
141
- output = Pathname("tmp/profile").join(script)
142
- output.mkpath
143
- script = Pathname("support/profile").join("#{script}.rb")
144
-
145
- args = [
146
- "-W0",
147
- "-Ilib",
148
- "-S", "ruby-prof",
149
- "-R", "mime/types",
150
- "-s", "self",
151
- "-p", "multi",
152
- "-f", output.to_s,
153
- script.to_s
154
- ]
155
- ruby args.join(" ")
138
+ task full: "benchmark:support" do
139
+ require "profile"
140
+ profile_full
156
141
  end
157
142
 
158
- task full: "tmp/profile" do
159
- ruby_prof "full"
143
+ task columnar: "benchmark:support" do
144
+ require "profile"
145
+ profile_columnar
160
146
  end
161
147
 
162
- task columnar: :support do
163
- ruby_prof "columnar"
164
- end
165
-
166
- task "columnar:full" => :support do
167
- ruby_prof "columnar_full"
168
- end
169
- end
170
-
171
- if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.0")
172
- namespace :test do
173
- desc "Run test coverage"
174
- task :coverage do
175
- spec.test_prelude = [
176
- 'require "simplecov"',
177
- 'SimpleCov.start("test_frameworks") { command_name "Minitest" }',
178
- 'gem "minitest"'
179
- ].join("; ")
180
- Rake::Task["test"].execute
181
- end
148
+ task "columnar:full" => "benchmark:support" do
149
+ require "profile"
150
+ profile_columnar_full
182
151
  end
183
152
  end
184
153
 
@@ -209,6 +178,11 @@ namespace :convert do
209
178
  task docs: "convert:docs:run"
210
179
  end
211
180
 
181
+ task :version do
182
+ require "mime/types/version"
183
+ puts MIME::Types::VERSION
184
+ end
185
+
212
186
  namespace :deps do
213
187
  task :top, [:number] => "benchmark:support" do |_, args|
214
188
  require "deps"
@@ -225,5 +199,3 @@ task :console do
225
199
  abort
226
200
  end
227
201
  end
228
-
229
- # vim: syntax=ruby
data/SECURITY.md ADDED
@@ -0,0 +1,7 @@
1
+ # mime-types Security
2
+
3
+ ## Security contact information
4
+
5
+ To report a security vulnerability, please use the
6
+ [Tidelift security contact](https://tidelift.com/security). Tidelift will
7
+ coordinate the fix and disclosure.
@@ -15,8 +15,10 @@ require "mime/type"
15
15
  class MIME::Type::Columnar < MIME::Type
16
16
  def initialize(container, content_type, extensions) # :nodoc:
17
17
  @container = container
18
+ @__priority_penalty = nil
18
19
  self.content_type = content_type
19
- self.extensions = extensions
20
+ @extensions = Set[*Array(extensions).flatten.compact].freeze
21
+ clear_sort_priority
20
22
  end
21
23
 
22
24
  def self.column(*methods, file: nil) # :nodoc:
@@ -51,6 +53,17 @@ class MIME::Type::Columnar < MIME::Type
51
53
  super
52
54
  end
53
55
 
56
+ def update_sort_priority
57
+ if @container.__fully_loaded?
58
+ super
59
+ else
60
+ obsolete = (@__sort_priority & (1 << 7)) != 0
61
+ registered = (@__sort_priority & (1 << 5)) == 0
62
+
63
+ @__priority_penalty = (obsolete ? 3 : 0) + (registered ? 0 : 2)
64
+ end
65
+ end
66
+
54
67
  class << self
55
68
  undef column
56
69
  end