Skip to content

A platform for community discussion. Free, open, simple.

FIX: whitelist uploads before creating thumbnail variants (#25013)

David Battersby1010bbf2ce90
diff --git a/plugins/chat/lib/chat/message_processor.rb b/plugins/chat/lib/chat/message_processor.rb
index 0ddadd13d00..74658ffde99 100644
--- a/plugins/chat/lib/chat/message_processor.rb
+++ b/plugins/chat/lib/chat/message_processor.rb
@@ -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