diff options
author | Nick Thomas <nick@gitlab.com> | 2018-01-10 21:10:42 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2018-01-11 16:06:25 +0300 |
commit | d2f83a10ea52a4fcbf380ddf01685bbc6ad7ee7a (patch) | |
tree | a175eff0d4680e947247038923c04a3bd4562e77 /lib/banzai | |
parent | 0a51eae58642d2c1df27166092efa2d75ec1cbe0 (diff) |
Ensure that emails contain absolute, rather than relative, links to user uploads
Diffstat (limited to 'lib/banzai')
-rw-r--r-- | lib/banzai/filter/relative_link_filter.rb | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/banzai/filter/relative_link_filter.rb b/lib/banzai/filter/relative_link_filter.rb index 5c197afd782..f6169b2c85d 100644 --- a/lib/banzai/filter/relative_link_filter.rb +++ b/lib/banzai/filter/relative_link_filter.rb @@ -50,15 +50,22 @@ module Banzai end def process_link_to_upload_attr(html_attr) - uri_parts = [html_attr.value] + path_parts = [html_attr.value] if group - uri_parts.unshift(relative_url_root, 'groups', group.full_path, '-') + path_parts.unshift(relative_url_root, 'groups', group.full_path, '-') elsif project - uri_parts.unshift(relative_url_root, project.full_path) + path_parts.unshift(relative_url_root, project.full_path) end - html_attr.value = File.join(*uri_parts) + path = File.join(*path_parts) + + html_attr.value = + if context[:only_path] + path + else + URI.join(Gitlab.config.gitlab.base_url, path).to_s + end end def process_link_to_repository_attr(html_attr) |