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.
This commit is contained in:
Javi Martín
2019-10-02 19:40:58 +02:00
parent 2aabf79fb4
commit 0b40865e61

View File

@@ -8,8 +8,8 @@ module TextWithLinksHelper
def auto_link_already_sanitized_html(html)
return if html.nil?
html = ActiveSupport::SafeBuffer.new(html) if html.is_a?(String)
return html.html_safe unless html.html_safe?
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