summaryrefslogtreecommitdiffstats
path: root/lib/redmine
diff options
context:
space:
mode:
authorMarius Balteanu <marius.balteanu@zitec.com>2022-09-26 22:34:44 +0000
committerMarius Balteanu <marius.balteanu@zitec.com>2022-09-26 22:34:44 +0000
commit0bb977cb4157eb0ca689a276abee25a4b5992bbc (patch)
tree5adfcb190e143ca2e9a6734cd2eb69a016aafe7e /lib/redmine
parentf733508d8a5068f713c0c8434485f047a4c5a288 (diff)
downloadredmine-0bb977cb4157eb0ca689a276abee25a4b5992bbc.tar.gz
redmine-0bb977cb4157eb0ca689a276abee25a4b5992bbc.zip
Add rel="noopener" to all external links with a target attribute (#37713).
Patch by Jens Krämer. git-svn-id: https://svn.redmine.org/redmine/trunk@21849 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/redmine')
-rw-r--r--lib/redmine/wiki_formatting/common_mark/external_links_filter.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/redmine/wiki_formatting/common_mark/external_links_filter.rb b/lib/redmine/wiki_formatting/common_mark/external_links_filter.rb
index 2aab08aa1..68ece55bb 100644
--- a/lib/redmine/wiki_formatting/common_mark/external_links_filter.rb
+++ b/lib/redmine/wiki_formatting/common_mark/external_links_filter.rb
@@ -43,6 +43,12 @@ module Redmine
klass,
(scheme == "mailto" ? "email" : "external")
].compact.join " "
+
+ if node["target"].present? && scheme != "mailto"
+ rel = node["rel"]&.split || []
+ rel << "noopener"
+ node["rel"] = rel.join(" ")
+ end
end
doc
end