diff --git a/app/logical/note_sanitizer.rb b/app/logical/note_sanitizer.rb index e786dc1f2..27ca58345 100644 --- a/app/logical/note_sanitizer.rb +++ b/app/logical/note_sanitizer.rb @@ -59,6 +59,9 @@ module NoteSanitizer text, :elements => ALLOWED_ELEMENTS, :attributes => ALLOWED_ATTRIBUTES, + :add_attributes => { + "a" => { "rel" => "nofollow" }, + }, :protocols => { "a" => { "href" => ["http", "https", :relative] diff --git a/test/unit/note_sanitizer_test.rb b/test/unit/note_sanitizer_test.rb index 3394219ea..e87ed67d7 100644 --- a/test/unit/note_sanitizer_test.rb +++ b/test/unit/note_sanitizer_test.rb @@ -16,5 +16,10 @@ class NoteSanitizerTest < ActiveSupport::TestCase body = '
test
' assert_equal('test
', NoteSanitizer.sanitize(body)) end + + should "mark links as nofollow" do + body = 'google' + assert_equal('google', NoteSanitizer.sanitize(body)) + end end end