Files
nairobi/app/helpers/text_with_links_helper.rb
Javi Martín 0b40865e61 Raise an exception when handling unsafe content
We were confused about what `.html_safe` did, and were automatically
marking as safe content which was not.
2019-10-08 18:46:20 +02:00

21 lines
573 B
Ruby

module TextWithLinksHelper
def sanitize_and_auto_link(text)
return unless text
sanitized = sanitize(text, tags: [], attributes: [])
Rinku.auto_link(sanitized, :all, 'target="_blank" rel="nofollow"').html_safe
end
def auto_link_already_sanitized_html(html)
return if html.nil?
raise "Could not add links because the content is not safe" unless html.html_safe?
Rinku.auto_link(html, :all, 'target="_blank" rel="nofollow"').html_safe
end
def simple_format_no_tags_no_sanitize(html)
simple_format(html, {}, sanitize: false)
end
end