Files
nairobi/app/helpers/text_with_links_helper.rb
Senén Rodero Rodríguez 4f0d1399f2 Fix html with links sanitization
Globalize attribute accessors were arriving here as Strings intead of
ActiveSupport::SafeBuffer so they were not sanitized correctly.
2019-06-27 09:19:36 +02:00

21 lines
584 B
Ruby

module TextWithLinksHelper
def text_with_links(text)
return unless text
sanitized = sanitize(text, tags: [], attributes: [])
Rinku.auto_link(sanitized, :all, 'target="_blank" rel="nofollow"').html_safe
end
def safe_html_with_links(html)
return if html.nil?
html = ActiveSupport::SafeBuffer.new(html) if html.is_a?(String)
return html.html_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