diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-24 18:07:55 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-24 18:07:55 +0000 |
commit | 603c7d4cac5e28bc1c75e50c23ed2cbe56f1aafc (patch) | |
tree | 907f5b8ee1b6f5aad396e95e3327a08400b9e8ea /app/uploaders | |
parent | 120f4aaedc8fe830a3f572491d240d8ee6addefb (diff) | |
download | gitlab-ce-603c7d4cac5e28bc1c75e50c23ed2cbe56f1aafc.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/uploaders')
-rw-r--r-- | app/uploaders/content_type_whitelist.rb | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/app/uploaders/content_type_whitelist.rb b/app/uploaders/content_type_whitelist.rb index b3975d7e2e0..3210d57b00c 100644 --- a/app/uploaders/content_type_whitelist.rb +++ b/app/uploaders/content_type_whitelist.rb @@ -26,14 +26,14 @@ module ContentTypeWhitelist # Here we override and extend CarrierWave's method that does not parse the # magic headers. def check_content_type_whitelist!(new_file) - new_file.content_type = mime_magic_content_type(new_file.path) + if content_type_whitelist + content_type = mime_magic_content_type(new_file.path) - if content_type_whitelist && !whitelisted_content_type?(new_file.content_type) - message = I18n.translate(:"errors.messages.content_type_whitelist_error", allowed_types: Array(content_type_whitelist).join(", ")) - raise CarrierWave::IntegrityError, message + unless whitelisted_content_type?(content_type) + message = I18n.translate(:"errors.messages.content_type_whitelist_error", allowed_types: Array(content_type_whitelist).join(", ")) + raise CarrierWave::IntegrityError, message + end end - - super(new_file) end def whitelisted_content_type?(content_type) |