Set nofollow on links in Markdown content

To disincentivize spamdexing, links in user-generated content should be
disavowed by annotation with `rel="nofollow"` attributes:

  - https://en.wikipedia.org/wiki/Nofollow

Automated spam has already targeted OSEM in the wild:

  - https://github.com/SeaGL/organization/issues/274

Ideally link annotation would be performed during Markdown rendering or
a single sanitization pass, but this is currently an unresolved issue:

  - https://github.com/vmg/redcarpet/issues/720
This commit is contained in:
Andrew Kvalheim 2023-03-03 16:51:01 -08:00
parent c54a8a1238
commit 80d7ac545c
2 changed files with 6 additions and 1 deletions

View file

@ -202,7 +202,7 @@ module FormatHelper
safe_links_only: true
}
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML.new(render_options), markdown_options)
sanitize(markdown.render(text))
sanitize(sanitize(markdown.render(text)), scrubber: Loofah::Scrubbers::NoFollow.new)
end
def markdown_hint(text='')