Commit 852bf484 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch '213468-skip-generating-smaller-design-images-for-tiff' into 'master'

Skip generating smaller Design Management designs for TIFFs

See merge request gitlab-org/gitlab!28875
parents ebf6b90a a844b1b9
...@@ -12,9 +12,15 @@ module DesignManagement ...@@ -12,9 +12,15 @@ module DesignManagement
include ObjectStorage::Concern include ObjectStorage::Concern
prepend ObjectStorage::Extension::RecordsUploads prepend ObjectStorage::Extension::RecordsUploads
# We currently cannot resize `image/ico` or `image/svg+xml` mime types. # We choose not to resize `image/ico` as we assume there will be no
# See https://gitlab.com/gitlab-org/gitlab/issues/207069 # benefit in generating an 432x230 sized icon.
MIME_TYPE_WHITELIST = %w(image/png image/jpeg image/bmp image/gif image/tiff).freeze #
# We currently cannot resize `image/tiff`.
# See https://gitlab.com/gitlab-org/gitlab/issues/207740
#
# We currently choose not to resize `image/svg+xml` for security reasons.
# See https://gitlab.com/gitlab-org/gitlab/issues/207740#note_302766171
MIME_TYPE_WHITELIST = %w(image/png image/jpeg image/bmp image/gif).freeze
process resize_to_fit: [432, 230] process resize_to_fit: [432, 230]
......
...@@ -15,6 +15,14 @@ describe DesignManagement::GenerateImageVersionsService do ...@@ -15,6 +15,14 @@ describe DesignManagement::GenerateImageVersionsService do
.from(nil).to(CarrierWave::SanitizedFile) .from(nil).to(CarrierWave::SanitizedFile)
end end
it 'skips generating image versions if the mime type is not whitelisted' do
stub_const('DesignManagement::DesignV432x230Uploader::MIME_TYPE_WHITELIST', [])
described_class.new(version).execute
expect(action.reload.image_v432x230.file).to eq(nil)
end
it 'skips generating image versions if the design file size is too large' do it 'skips generating image versions if the design file size is too large' do
stub_const("#{described_class.name}::MAX_DESIGN_SIZE", 1.byte) stub_const("#{described_class.name}::MAX_DESIGN_SIZE", 1.byte)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment