Skip to content

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

SECURITY: Limit length of edit reason column

Penar Musarajdcc825bda505
diff --git a/app/models/post.rb b/app/models/post.rb
index db19fa62db0..86cfa5962a4 100644
--- a/app/models/post.rb
+++ b/app/models/post.rb
@@ -64,6 +64,7 @@ class Post < ActiveRecord::Base
has_many :reviewables, as: :target, dependent: :destroy
validates_with PostValidator, unless: :skip_validation
+ validates :edit_reason, length: { maximum: 1000 }
after_commit :index_search
diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb
index 66ece7915df..12a46d8f77c 100644
--- a/spec/models/post_spec.rb
+++ b/spec/models/post_spec.rb
@@ -61,6 +61,7 @@ RSpec.describe Post do
end
it { is_expected.to validate_presence_of :raw }
+ it { is_expected.to validate_length_of(:edit_reason).is_at_most(1000) }
# Min/max body lengths, respecting padding
it { is_expected.not_to allow_value("x").for(:raw) }