Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip content type filters where possible. #2464

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/carrierwave/uploader/content_type_blacklist.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ def content_type_blacklist; end
private

def check_content_type_blacklist!(new_file)
return unless content_type_blacklist

content_type = new_file.content_type
if content_type_blacklist && blacklisted_content_type?(content_type)
if blacklisted_content_type?(content_type)
raise CarrierWave::IntegrityError, I18n.translate(:"errors.messages.content_type_blacklist_error", content_type: content_type)
end
end
Expand Down
4 changes: 3 additions & 1 deletion lib/carrierwave/uploader/content_type_whitelist.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ def content_type_whitelist; end
private

def check_content_type_whitelist!(new_file)
return unless content_type_whitelist

content_type = new_file.content_type
if content_type_whitelist && !whitelisted_content_type?(content_type)
if !whitelisted_content_type?(content_type)
raise CarrierWave::IntegrityError, I18n.translate(:"errors.messages.content_type_whitelist_error", content_type: content_type, allowed_types: Array(content_type_whitelist).join(", "))
end
end
Expand Down
4 changes: 3 additions & 1 deletion lib/carrierwave/uploader/extension_blacklist.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ def extension_blacklist; end
private

def check_extension_blacklist!(new_file)
return unless extension_blacklist

extension = new_file.extension.to_s
if extension_blacklist && blacklisted_extension?(extension)
if blacklisted_extension?(extension)
raise CarrierWave::IntegrityError, I18n.translate(:"errors.messages.extension_blacklist_error", extension: new_file.extension.inspect, prohibited_types: Array(extension_blacklist).join(", "))
end
end
Expand Down
4 changes: 3 additions & 1 deletion lib/carrierwave/uploader/extension_whitelist.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ def extension_whitelist; end
private

def check_extension_whitelist!(new_file)
return unless extension_whitelist

extension = new_file.extension.to_s
if extension_whitelist && !whitelisted_extension?(extension)
if !whitelisted_extension?(extension)
raise CarrierWave::IntegrityError, I18n.translate(:"errors.messages.extension_whitelist_error", extension: new_file.extension.inspect, allowed_types: Array(extension_whitelist).join(", "))
end
end
Expand Down