mirror of
https://github.com/discourse/discourse.git
synced 2025-04-24 21:54:31 +08:00
FIX: whitelist uploads before creating thumbnail variants (#25013)
Only attempt to create thumbnails for whitelisted upload extensions.
This commit is contained in:
parent
9ebe21df82
commit
1010bbf2ce
@ -3,6 +3,7 @@
|
||||
module Chat
|
||||
class MessageProcessor
|
||||
include ::CookedProcessorMixin
|
||||
IMG_FILETYPES = %w[jpg jpeg gif png heic heif webp]
|
||||
|
||||
def initialize(chat_message, opts = {})
|
||||
@model = chat_message
|
||||
@ -22,7 +23,11 @@ module Chat
|
||||
end
|
||||
|
||||
def process_thumbnails
|
||||
return if !SiteSetting.create_thumbnails
|
||||
|
||||
@model.uploads.each do |upload|
|
||||
next if upload.blank? || IMG_FILETYPES.exclude?(upload.extension.downcase)
|
||||
|
||||
if upload.width <= SiteSetting.max_image_width &&
|
||||
upload.height <= SiteSetting.max_image_height
|
||||
return false
|
||||
|
Loading…
x
Reference in New Issue
Block a user