From 229a10e142abd9df20373d3f47bce37675b3d86e Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 16 Oct 2017 10:46:01 +1100 Subject: [PATCH] Missed a whitelist, compensate for strict classes --- .../pretty-text/engines/discourse-markdown/emoji.js.es6 | 2 +- spec/models/post_analyzer_spec.rb | 4 ++++ spec/models/post_spec.rb | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/pretty-text/engines/discourse-markdown/emoji.js.es6 b/app/assets/javascripts/pretty-text/engines/discourse-markdown/emoji.js.es6 index 1f0acfc32ce..522edbe7669 100644 --- a/app/assets/javascripts/pretty-text/engines/discourse-markdown/emoji.js.es6 +++ b/app/assets/javascripts/pretty-text/engines/discourse-markdown/emoji.js.es6 @@ -241,5 +241,5 @@ export function setup(helper) { ); }); - helper.whiteList(['img[class=emoji]']); + helper.whiteList(['img[class=emoji]','img[class=emoji emoji-custom]']); } diff --git a/spec/models/post_analyzer_spec.rb b/spec/models/post_analyzer_spec.rb index fda91800715..c82341e881d 100644 --- a/spec/models/post_analyzer_spec.rb +++ b/spec/models/post_analyzer_spec.rb @@ -113,21 +113,25 @@ describe PostAnalyzer do it "doesn't count avatars as images" do post_analyzer = PostAnalyzer.new(raw_post_with_avatars, default_topic_id) + PrettyText.stubs(:cook).returns(raw_post_with_avatars) expect(post_analyzer.image_count).to eq(0) end it "doesn't count favicons as images" do post_analyzer = PostAnalyzer.new(raw_post_with_favicon, default_topic_id) + PrettyText.stubs(:cook).returns(raw_post_with_favicon) expect(post_analyzer.image_count).to eq(0) end it "doesn't count thumbnails as images" do post_analyzer = PostAnalyzer.new(raw_post_with_thumbnail, default_topic_id) + PrettyText.stubs(:cook).returns(raw_post_with_thumbnail) expect(post_analyzer.image_count).to eq(0) end it "doesn't count whitelisted images" do Post.stubs(:white_listed_image_classes).returns(["classy"]) + PrettyText.stubs(:cook).returns(raw_post_with_two_classy_images) post_analyzer = PostAnalyzer.new(raw_post_with_two_classy_images, default_topic_id) expect(post_analyzer.image_count).to eq(0) end diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index b387c7e179e..99b5e898bce 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -189,15 +189,19 @@ describe Post do end it "doesn't count favicons as images" do + PrettyText.stubs(:cook).returns(post_with_favicon.raw) expect(post_with_favicon.image_count).to eq(0) end it "doesn't count thumbnails as images" do + PrettyText.stubs(:cook).returns(post_with_thumbnail.raw) expect(post_with_thumbnail.image_count).to eq(0) end it "doesn't count whitelisted images" do Post.stubs(:white_listed_image_classes).returns(["classy"]) + # I dislike this, but passing in a custom whitelist is hard + PrettyText.stubs(:cook).returns(post_with_two_classy_images.raw) expect(post_with_two_classy_images.image_count).to eq(0) end