Files
nairobi/app/helpers/text_with_links_helper.rb
Javi Martín 89402bdbf6 Use raw instead of html_safe
They do the exact same thing; however `html_safe` might confuse
developers into thinking it will make the HTML safe. Using `raw` makes
it clear that we're inserting the text without escaping it.
2019-10-08 19:10:13 +02:00

21 lines
534 B
Ruby

module TextWithLinksHelper
def sanitize_and_auto_link(text)
return unless text
sanitized = sanitize(text, tags: [], attributes: [])
auto_link_already_sanitized_html(sanitized)
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?
raw Rinku.auto_link(html, :all, 'target="_blank" rel="nofollow"')
end
def simple_format_no_tags_no_sanitize(html)
simple_format(html, {}, sanitize: false)
end
end