We were using `Rinku.auto_link` the same way twice. And it makes sense that the method `sanitize_and_auto_link` first sanitizes the text and then calls `auto_link_already_sanitized_text`.
21 lines
540 B
Ruby
21 lines
540 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?
|
|
|
|
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
|