diff options
author | Stan Hu <stanhu@gmail.com> | 2019-06-28 18:08:35 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2019-06-28 22:08:46 -0700 |
commit | 0e341a6e58fc3afca20781cf1f4cbf214b9503ba (patch) | |
tree | e7956368ac4d93dd6c900a676fc095a0d52f651d /lib/banzai | |
parent | df717efaabd9ab11806495244e1e5fa515c01f1f (diff) | |
download | gitlab-ce-0e341a6e58fc3afca20781cf1f4cbf214b9503ba.tar.gz |
Fix attachments using the wrong URLs in e-mailssh-fix-issue-63910
Prior to https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/29889,
only the project context were set for the Markdown renderer. For a note
on an issuable, the group context was set to `nil` because
`note.noteable.try(:group)` attempted to get the issuable's group, which
doesn't exist.
To make group notifications work, now both the project and group context
are set. The context gets passed to `RelativeLinkFilter`, which
previously assumed that it wasn't possible to have both a group and a
project in the Markdown context. However, if a group were defined, it
would take precedence, and the URL rendered for uploads would be
`/group/-/uploads` instead of `/group/project/uploads/`. This led to
404s in e-mails.
However, now that we have both project and group in the context, we
render the Markdown giving priority to the project context if is set.
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/63910
Diffstat (limited to 'lib/banzai')
-rw-r--r-- | lib/banzai/filter/relative_link_filter.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/banzai/filter/relative_link_filter.rb b/lib/banzai/filter/relative_link_filter.rb index 80c84c0f622..88836e12e61 100644 --- a/lib/banzai/filter/relative_link_filter.rb +++ b/lib/banzai/filter/relative_link_filter.rb @@ -56,10 +56,10 @@ module Banzai def process_link_to_upload_attr(html_attr) path_parts = [Addressable::URI.unescape(html_attr.value)] - if group - path_parts.unshift(relative_url_root, 'groups', group.full_path, '-') - elsif project + if project path_parts.unshift(relative_url_root, project.full_path) + elsif group + path_parts.unshift(relative_url_root, 'groups', group.full_path, '-') else path_parts.unshift(relative_url_root) end |