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.rbindex db19fa62db0..86cfa5962a4 100644--- a/app/models/post.rb+++ b/app/models/post.rb@@ -64,6 +64,7 @@ class Post < ActiveRecord::Basehas_many :reviewables, as: :target, dependent: :destroyvalidates_with PostValidator, unless: :skip_validation+ validates :edit_reason, length: { maximum: 1000 }after_commit :index_searchdiff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rbindex 66ece7915df..12a46d8f77c 100644--- a/spec/models/post_spec.rb+++ b/spec/models/post_spec.rb@@ -61,6 +61,7 @@ RSpec.describe Post doendit { 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 paddingit { is_expected.not_to allow_value("x").for(:raw) }