Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-08-26 17:36:54 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-08-26 17:36:54 +0300
commitdaf5ae5bd439f1f32363d410129d5b9e73fbb539 (patch)
tree6d670487dc3dccf1a0c3e6b8337e5b4ab9da4ee9 /lib/banzai
parent6e8c2290dab8ae1612dff80e312911bc1147edaa (diff)
Add latest changes from gitlab-org/security/gitlab@15-3-stable-ee
Diffstat (limited to 'lib/banzai')
-rw-r--r--lib/banzai/filter/image_link_filter.rb13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/banzai/filter/image_link_filter.rb b/lib/banzai/filter/image_link_filter.rb
index 60881b5f511..262c0b5340d 100644
--- a/lib/banzai/filter/image_link_filter.rb
+++ b/lib/banzai/filter/image_link_filter.rb
@@ -34,17 +34,20 @@ module Banzai
img.remove_attribute('data-diagram-src')
end
- link.children = if link_replaces_image
- img['alt'] || img['data-src'] || img['src']
- else
- img.clone
- end
+ link.children = link_replaces_image ? link_children(img) : img.clone
img.replace(link)
end
doc
end
+
+ private
+
+ def link_children(img)
+ [img['alt'], img['data-src'], img['src']]
+ .map { |f| Sanitize.fragment(f).presence }.compact.first || ''
+ end
end
end
end