mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Merge pull request #3131 from AndrewKvalheim/nofollow
Set `nofollow` on user-generated links
This commit is contained in:
commit
8b909a95c9
2 changed files with 14 additions and 1 deletions
|
|
@ -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='')
|
||||
|
|
|
|||
|
|
@ -16,5 +16,18 @@ describe FormatHelper, type: :helper do
|
|||
it 'should return HTML for header markdown' do
|
||||
expect(markdown('# this is my header')).to eq "<h1>this is my header</h1>\n"
|
||||
end
|
||||
|
||||
it 'escapes input HTML' do
|
||||
expect(markdown('<em>*a*</em>')).to eq "<p><em><em>a</em></em></p>\n"
|
||||
end
|
||||
|
||||
it 'removes unallowed elements' do
|
||||
expect(markdown('<em>*<style>a</style>*</em>', false)).to eq "<p><em><em>a</em></em></p>\n"
|
||||
end
|
||||
|
||||
it 'sets nofollow on links' do
|
||||
expect(markdown('[a](https://example.com/)'))
|
||||
.to eq "<p><a href=\"https://example.com/\" rel=\"nofollow\">a</a></p>\n"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue