mirror of
https://github.com/discourse/discourse.git
synced 2025-09-05 08:59:27 +08:00
rel nofollow, on by default to protect forums from spam etc. we should consider lifting it at high trust by default.
This commit is contained in:
parent
004d4bf4e1
commit
543845c673
4 changed files with 48 additions and 1 deletions
|
@ -75,6 +75,24 @@ test
|
|||
.should == "<pre><code>```\nhello\n```\n</code></pre>"
|
||||
end
|
||||
end
|
||||
|
||||
describe "rel nofollow" do
|
||||
before do
|
||||
SiteSetting.stubs(:add_rel_nofollow_to_user_content).returns(true)
|
||||
end
|
||||
|
||||
it "should inject nofollow in all user provided links" do
|
||||
PrettyText.cook('<a href="http://cnn.com">cnn</a>').should =~ /nofollow/
|
||||
end
|
||||
|
||||
it "should not inject nofollow in all local links" do
|
||||
(PrettyText.cook("<a href='#{Discourse.base_url}/test.html'>cnn</a>") !~ /nofollow/).should be_true
|
||||
end
|
||||
|
||||
it "should not inject nofollow in all subdomain links" do
|
||||
(PrettyText.cook("<a href='#{Discourse.base_url.sub('http://', 'http://bla.')}/test.html'>cnn</a>") !~ /nofollow/).should be_true
|
||||
end
|
||||
end
|
||||
|
||||
describe "Excerpt" do
|
||||
it "should preserve links" do
|
||||
|
@ -130,6 +148,7 @@ test
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
describe "apply cdn" do
|
||||
it "should detect bare links to images and apply a CDN" do
|
||||
PrettyText.apply_cdn("<a href='/hello.png'>hello</a><img src='/a.jpeg'>","http://a.com").should ==
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue