diff options
author | Jacob Schatz <jschatz@gitlab.com> | 2017-03-16 00:21:48 +0300 |
---|---|---|
committer | DJ Mountney <david@twkie.net> | 2017-03-18 05:14:48 +0300 |
commit | c0873f946c27da9696d026860d7d2f1e768c8ebc (patch) | |
tree | f06a4f1aca45a41ff690530a1950f745b7fe55b3 /lib | |
parent | 7d12784009bb972218cc99422c48be150157d012 (diff) |
Merge branch 'fix-links-target-blank' into 'security'
Adds rel="noopener noreferrer" to all links with target="_blank"
See merge request !2071
Diffstat (limited to 'lib')
-rw-r--r-- | lib/banzai/filter/image_link_filter.rb | 4 | ||||
-rw-r--r-- | lib/banzai/filter/video_link_filter.rb | 1 |
2 files changed, 3 insertions, 2 deletions
diff --git a/lib/banzai/filter/image_link_filter.rb b/lib/banzai/filter/image_link_filter.rb index 651b55523c0..123c92fd250 100644 --- a/lib/banzai/filter/image_link_filter.rb +++ b/lib/banzai/filter/image_link_filter.rb @@ -2,7 +2,6 @@ module Banzai module Filter # HTML filter that wraps links around inline images. class ImageLinkFilter < HTML::Pipeline::Filter - # Find every image that isn't already wrapped in an `a` tag, create # a new node (a link to the image source), copy the image as a child # of the anchor, and then replace the img with the link-wrapped version. @@ -12,7 +11,8 @@ module Banzai 'a', class: 'no-attachment-icon', href: img['src'], - target: '_blank' + target: '_blank', + rel: 'noopener noreferrer' ) link.children = img.clone diff --git a/lib/banzai/filter/video_link_filter.rb b/lib/banzai/filter/video_link_filter.rb index b64a1287d4d..35cb10eae5d 100644 --- a/lib/banzai/filter/video_link_filter.rb +++ b/lib/banzai/filter/video_link_filter.rb @@ -43,6 +43,7 @@ module Banzai element['title'] || element['alt'], href: element['src'], target: '_blank', + rel: 'noopener noreferrer', title: "Download '#{element['title'] || element['alt']}'") download_paragraph = doc.document.create_element('p') download_paragraph.children = link |