-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rails/rails#42225 identified that some of the content types used as defaults by Active Storage aren't recognized by `mini_mime`. This means that in practice code like [this](https://github.com/rails/rails/pull/42225/files#diff-7a3ec24c556b138abdbd67066ab5125b73528e45891d83142e417d3944194128R116) will crash or not function correctly. In [this](https://github.com/rails/rails/pull/42225/files#diff-c2010824d2d2e8d841ff4fc058c264c12d870e893025b153e6de571fba6b6c6cR194) example, a file with content_type `image/jpg` is treated as a PNG by the representer, since `image/jpg` isn't a valid content type according to `mini_mime`. I don't think the default content_types should include formats that have never actually worked, so I'm proposing we remove them from the defaults.
- Loading branch information
1 parent
97b7e1a
commit 9fcbcc5
Showing
7 changed files
with
101 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# frozen_string_literal: true | ||
|
||
require "test_helper" | ||
require "database/setup" | ||
|
||
class ActiveStorage::EngineTest < ActiveSupport::TestCase | ||
test "all default content types are recognized by mini_mime" do | ||
exceptions = ActiveStorage::Blob::INVALID_VARIABLE_CONTENT_TYPES_DEPRECATED_IN_RAILS_7 + ActiveStorage::Blob::INVALID_VARIABLE_CONTENT_TYPES_TO_SERVE_AS_BINARY_DEPRECATED_IN_RAILS_7 | ||
|
||
ActiveStorage.variable_content_types.each do |content_type| | ||
next if exceptions.include?(content_type) # remove this line in Rails 7.1 | ||
|
||
assert_equal content_type, MiniMime.lookup_by_content_type(content_type).content_type | ||
end | ||
|
||
ActiveStorage.web_image_content_types.each do |content_type| | ||
next if exceptions.include?(content_type) # remove this line in Rails 7.1 | ||
|
||
assert_equal content_type, MiniMime.lookup_by_content_type(content_type).content_type | ||
end | ||
|
||
ActiveStorage.content_types_to_serve_as_binary.each do |content_type| | ||
next if exceptions.include?(content_type) # remove this line in Rails 7.1 | ||
|
||
assert_equal content_type, MiniMime.lookup_by_content_type(content_type).content_type | ||
end | ||
|
||
ActiveStorage.content_types_allowed_inline.each do |content_type| | ||
next if exceptions.include?(content_type) # remove this line in Rails 7.1 | ||
|
||
assert_equal content_type, MiniMime.lookup_by_content_type(content_type).content_type | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters