FIX: Links in quotes should be counted for rate limits

This commit is contained in:
Robin Ward 2018-02-20 20:41:27 -05:00
parent b6e82815bd
commit 5c40ae9e63
2 changed files with 8 additions and 1 deletions

View File

@ -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

View File

@ -169,6 +169,7 @@ describe Post do
let(:post_two_images) { post_with_body("<img src='http://discourse.org/logo.png'> <img src='http://bbc.co.uk/sherlock.jpg'>", newuser) }
let(:post_with_avatars) { post_with_body('<img alt="smiley" title=":smiley:" src="/assets/emoji/smiley.png" class="avatar"> <img alt="wink" title=":wink:" src="/assets/emoji/wink.png" class="avatar">', newuser) }
let(:post_with_favicon) { post_with_body('<img src="/assets/favicons/wikipedia.png" class="favicon">', newuser) }
let(:post_image_within_quote) { post_with_body('[quote]<img src="coolimage.png">[/quote]', newuser) }
let(:post_with_thumbnail) { post_with_body('<img src="/assets/emoji/smiley.png" class="thumbnail">', newuser) }
let(:post_with_two_classy_images) { post_with_body("<img src='http://discourse.org/logo.png' class='classy'> <img src='http://bbc.co.uk/sherlock.jpg' class='classy'>", 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