A platform for community discussion. Free, open, simple.
SECURITY: use rstrip instead of regex gsub to prevent ReDOS (#19737)
Alan Guo Xiang Tan918dd4d63596
diff --git a/lib/post_creator.rb b/lib/post_creator.rbindex 2cf45b0a8f4..7cded3c4863 100644--- a/lib/post_creator.rb+++ b/lib/post_creator.rb@@ -514,7 +514,7 @@ class PostCreatorenddef setup_post- @opts[:raw] = TextCleaner.normalize_whitespaces(@opts[:raw] || '').gsub(/\s+\z/, "")+ @opts[:raw] = TextCleaner.normalize_whitespaces(@opts[:raw] || '').rstrippost = Post.new(raw: @opts[:raw],topic_id: @topic.try(:id),diff --git a/lib/post_revisor.rb b/lib/post_revisor.rbindex 7fc1ff8144b..d6dd390ec9d 100644--- a/lib/post_revisor.rb+++ b/lib/post_revisor.rb@@ -274,7 +274,7 @@ class PostRevisorenddef cleanup_whitespaces(raw)- raw.present? ? TextCleaner.normalize_whitespaces(raw).gsub(/\s+\z/, "") : ""+ raw.present? ? TextCleaner.normalize_whitespaces(raw).rstrip : ""enddef should_revise?