From 0b40865e61fd4f982557dee19c583eac6ccc4af4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Wed, 2 Oct 2019 19:40:58 +0200 Subject: [PATCH] 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. --- app/helpers/text_with_links_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/text_with_links_helper.rb b/app/helpers/text_with_links_helper.rb index 698990538..e1d8dbc54 100644 --- a/app/helpers/text_with_links_helper.rb +++ b/app/helpers/text_with_links_helper.rb @@ -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