From 02f1c04fabab221130de8dfb5611be81825b193b Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Sun, 22 Mar 2020 17:56:49 +0100 Subject: Make sanitizer *not* add no-referrer etc. in local markdown toots if the link is “safe” MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/lib/sanitize_config.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'app/lib/sanitize_config.rb') diff --git a/app/lib/sanitize_config.rb b/app/lib/sanitize_config.rb index 8bbcca4ce..34793ed93 100644 --- a/app/lib/sanitize_config.rb +++ b/app/lib/sanitize_config.rb @@ -60,7 +60,10 @@ class Sanitize node = env[:node] rel = (node['rel'] || '').split(' ') & ['tag'] - node['rel'] = (['nofollow', 'noopener', 'noreferrer'] + rel).join(' ') + unless env[:config][:outgoing] && TagManager.instance.local_url?(node['href']) + rel += ['nofollow', 'noopener', 'noreferrer'] + end + node['rel'] = rel.join(' ') end UNSUPPORTED_HREF_TRANSFORMER = lambda do |env| @@ -103,8 +106,8 @@ class Sanitize transformers: [ CLASS_WHITELIST_TRANSFORMER, IMG_TAG_TRANSFORMER, - LINK_REL_TRANSFORMER, UNSUPPORTED_HREF_TRANSFORMER, + LINK_REL_TRANSFORMER, ] ) -- cgit