From 2d0c99636af1a74d6046541361f0652c96e08030 Mon Sep 17 00:00:00 2001 From: Arpit Jalan Date: Sun, 20 Nov 2016 18:19:14 +0530 Subject: [PATCH] do not add rel noreferrer --- lib/pretty_text.rb | 4 ++-- spec/components/cooked_post_processor_spec.rb | 8 ++++---- spec/components/pretty_text_spec.rb | 2 +- spec/models/post_analyzer_spec.rb | 2 +- spec/models/post_spec.rb | 4 ++-- spec/models/user_profile_spec.rb | 12 ++++++------ 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/pretty_text.rb b/lib/pretty_text.rb index 4ad0c96c3ca..71f68d173c0 100644 --- a/lib/pretty_text.rb +++ b/lib/pretty_text.rb @@ -261,11 +261,11 @@ module PrettyText whitelist.any?{|u| uri.host == u || uri.host.ends_with?("." << u)} # we are good no need for nofollow else - l["rel"] = "nofollow noopener noreferrer" + l["rel"] = "nofollow noopener" end rescue URI::InvalidURIError, URI::InvalidComponentError # add a nofollow anyway - l["rel"] = "nofollow noopener noreferrer" + l["rel"] = "nofollow noopener" end end end diff --git a/spec/components/cooked_post_processor_spec.rb b/spec/components/cooked_post_processor_spec.rb index 8e95b49e83c..46db958932d 100644 --- a/spec/components/cooked_post_processor_spec.rb +++ b/spec/components/cooked_post_processor_spec.rb @@ -446,7 +446,7 @@ describe CookedPostProcessor do it "uses schemaless url for uploads" do cpp.optimize_urls - expect(cpp.html).to match_html '

Link

Google

text.txt (20 Bytes)
:smile:

' + expect(cpp.html).to match_html '

Link

Google

text.txt (20 Bytes)
:smile:

' end context "when CDN is enabled" do @@ -454,20 +454,20 @@ describe CookedPostProcessor do it "does use schemaless CDN url for http uploads" do Rails.configuration.action_controller.stubs(:asset_host).returns("http://my.cdn.com") cpp.optimize_urls - expect(cpp.html).to match_html '

Link

Google

text.txt (20 Bytes)
:smile:

' + expect(cpp.html).to match_html '

Link

Google

text.txt (20 Bytes)
:smile:

' end it "does not use schemaless CDN url for https uploads" do Rails.configuration.action_controller.stubs(:asset_host).returns("https://my.cdn.com") cpp.optimize_urls - expect(cpp.html).to match_html '

Link

Google

text.txt (20 Bytes)
:smile:

' + expect(cpp.html).to match_html '

Link

Google

text.txt (20 Bytes)
:smile:

' end it "does not use CDN when login is required" do SiteSetting.login_required = true Rails.configuration.action_controller.stubs(:asset_host).returns("http://my.cdn.com") cpp.optimize_urls - expect(cpp.html).to match_html '

Link

Google

text.txt (20 Bytes)
:smile:

' + expect(cpp.html).to match_html '

Link

Google

text.txt (20 Bytes)
:smile:

' end end diff --git a/spec/components/pretty_text_spec.rb b/spec/components/pretty_text_spec.rb index 0105e0ae043..6066d93e028 100644 --- a/spec/components/pretty_text_spec.rb +++ b/spec/components/pretty_text_spec.rb @@ -77,7 +77,7 @@ HTML end it "should inject nofollow in all user provided links" do - expect(PrettyText.cook('cnn')).to match(/nofollow noopener noreferrer/) + expect(PrettyText.cook('cnn')).to match(/nofollow noopener/) end it "should not inject nofollow in all local links" do diff --git a/spec/models/post_analyzer_spec.rb b/spec/models/post_analyzer_spec.rb index 8b549af7178..91cefd382b2 100644 --- a/spec/models/post_analyzer_spec.rb +++ b/spec/models/post_analyzer_spec.rb @@ -200,7 +200,7 @@ describe PostAnalyzer do it "ignores oneboxes" do post_analyzer = PostAnalyzer.new("Hello @Jake\n#{url}", default_topic_id) - post_analyzer.stubs(:cook).returns("

Hello @Jake
@Finn

") + post_analyzer.stubs(:cook).returns("

Hello @Jake
@Finn

") expect(post_analyzer.raw_mentions).to eq(['jake']) end diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index 0ce0ce9c576..1e827c0e6d4 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -812,7 +812,7 @@ describe Post do it "should add nofollow to links in the post for trust levels below 3" do post.user.trust_level = 2 post.save - expect(post.cooked).to match(/nofollow noopener noreferrer/) + expect(post.cooked).to match(/nofollow noopener/) end it "when tl3_links_no_follow is false, should not add nofollow for trust level 3 and higher" do @@ -826,7 +826,7 @@ describe Post do SiteSetting.stubs(:tl3_links_no_follow).returns(true) post.user.trust_level = 3 post.save - expect(post.cooked).to match(/nofollow noopener noreferrer/) + expect(post.cooked).to match(/nofollow noopener/) end end diff --git a/spec/models/user_profile_spec.rb b/spec/models/user_profile_spec.rb index 90918ffe154..d6b2c6ac01f 100644 --- a/spec/models/user_profile_spec.rb +++ b/spec/models/user_profile_spec.rb @@ -121,8 +121,8 @@ describe UserProfile do it 'includes the link as nofollow if the user is not new' do user.user_profile.send(:cook) - expect(user_profile.bio_excerpt).to match_html("I love http://discourse.org") - expect(user_profile.bio_processed).to match_html("

I love http://discourse.org

") + expect(user_profile.bio_excerpt).to match_html("I love http://discourse.org") + expect(user_profile.bio_processed).to match_html("

I love http://discourse.org

") end it 'removes the link if the user is new' do @@ -160,8 +160,8 @@ describe UserProfile do created_user.save created_user.reload created_user.change_trust_level!(TrustLevel[2]) - expect(created_user.user_profile.bio_excerpt).to match_html("I love http://discourse.org") - expect(created_user.user_profile.bio_processed).to match_html("

I love http://discourse.org

") + expect(created_user.user_profile.bio_excerpt).to match_html("I love http://discourse.org") + expect(created_user.user_profile.bio_processed).to match_html("

I love http://discourse.org

") end end @@ -171,8 +171,8 @@ describe UserProfile do it 'includes the link with nofollow if the user is trust level 3 or higher' do user.trust_level = TrustLevel[3] user_profile.send(:cook) - expect(user_profile.bio_excerpt).to match_html("I love http://discourse.org") - expect(user_profile.bio_processed).to match_html("

I love http://discourse.org

") + expect(user_profile.bio_excerpt).to match_html("I love http://discourse.org") + expect(user_profile.bio_processed).to match_html("

I love http://discourse.org

") end end end