notes: mark links as nofollow.
This commit is contained in:
@@ -59,6 +59,9 @@ module NoteSanitizer
|
|||||||
text,
|
text,
|
||||||
:elements => ALLOWED_ELEMENTS,
|
:elements => ALLOWED_ELEMENTS,
|
||||||
:attributes => ALLOWED_ATTRIBUTES,
|
:attributes => ALLOWED_ATTRIBUTES,
|
||||||
|
:add_attributes => {
|
||||||
|
"a" => { "rel" => "nofollow" },
|
||||||
|
},
|
||||||
:protocols => {
|
:protocols => {
|
||||||
"a" => {
|
"a" => {
|
||||||
"href" => ["http", "https", :relative]
|
"href" => ["http", "https", :relative]
|
||||||
|
|||||||
@@ -16,5 +16,10 @@ class NoteSanitizerTest < ActiveSupport::TestCase
|
|||||||
body = '<p style="font-size: 1em;">test</p>'
|
body = '<p style="font-size: 1em;">test</p>'
|
||||||
assert_equal('<p style="font-size: 1em;">test</p>', NoteSanitizer.sanitize(body))
|
assert_equal('<p style="font-size: 1em;">test</p>', NoteSanitizer.sanitize(body))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "mark links as nofollow" do
|
||||||
|
body = '<a href="http://www.google.com">google</a>'
|
||||||
|
assert_equal('<a href="http://www.google.com" rel="nofollow">google</a>', NoteSanitizer.sanitize(body))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user