mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
SECURITY: Limit ThemeField value length to prevent DoS (#22087)
Co-authored-by: Daniel Waterworth <me@danielwaterworth.com>
This commit is contained in:
@@ -5,6 +5,8 @@ class ThemeField < ActiveRecord::Base
|
||||
has_one :javascript_cache, dependent: :destroy
|
||||
has_one :upload_reference, as: :target, dependent: :destroy
|
||||
|
||||
validates :value, { length: { maximum: 1024**2 } }
|
||||
|
||||
after_save do
|
||||
if self.type_id == ThemeField.types[:theme_upload_var] && saved_change_to_upload_id?
|
||||
UploadReference.ensure_exist!(upload_ids: [self.upload_id], target: self)
|
||||
|
||||
Reference in New Issue
Block a user