From 5c40ae9e63e5071503919c38f4f04e8f0532de69 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Tue, 20 Feb 2018 20:41:27 -0500 Subject: [PATCH] FIX: Links in quotes should be counted for rate limits --- app/models/post_analyzer.rb | 2 +- spec/models/post_spec.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/models/post_analyzer.rb b/app/models/post_analyzer.rb index ddcfa2fd0c0..57e67c5efae 100644 --- a/app/models/post_analyzer.rb +++ b/app/models/post_analyzer.rb @@ -130,7 +130,7 @@ class PostAnalyzer def cooked_stripped @cooked_stripped ||= begin doc = Nokogiri::HTML.fragment(cook(@raw, topic_id: @topic_id)) - doc.css("pre, code, aside.quote, .onebox, .elided").remove + doc.css("pre, code, aside.quote > .title, aside.quote .mention, .onebox, .elided").remove doc end end diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index 9ccf9a80df2..b5571fb370e 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -169,6 +169,7 @@ describe Post do let(:post_two_images) { post_with_body(" ", newuser) } let(:post_with_avatars) { post_with_body('smiley wink', newuser) } let(:post_with_favicon) { post_with_body('', newuser) } + let(:post_image_within_quote) { post_with_body('[quote][/quote]', newuser) } let(:post_with_thumbnail) { post_with_body('', newuser) } let(:post_with_two_classy_images) { post_with_body(" ", newuser) } @@ -198,6 +199,12 @@ describe Post do expect(post_one_image).not_to be_valid end + it "doesn't allow more than `min_trust_to_post_images`" do + SiteSetting.min_trust_to_post_images = 4 + post_one_image.user.trust_level = 3 + expect(post_image_within_quote).not_to be_valid + end + it "doesn't allow more than `min_trust_to_post_images`" do SiteSetting.min_trust_to_post_images = 4 post_one_image.user.trust_level = 4