Commit 51df2ca5 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'bug/63162-duplicate_path_in_links' into 'master'

Do not rewrite relative links for system notes

Closes #63162

See merge request gitlab-org/gitlab-ce!29825
parents 18344feb 35a39c1d
...@@ -457,7 +457,7 @@ class Note < ApplicationRecord ...@@ -457,7 +457,7 @@ class Note < ApplicationRecord
end end
def banzai_render_context(field) def banzai_render_context(field)
super.merge(noteable: noteable) super.merge(noteable: noteable, system_note: system?)
end end
def retrieve_upload(_identifier, paths) def retrieve_upload(_identifier, paths)
......
---
title: Fixed 'diff version changes' link not working
merge_request: 29825
author:
type: fixed
...@@ -17,6 +17,8 @@ module Banzai ...@@ -17,6 +17,8 @@ module Banzai
include Gitlab::Utils::StrongMemoize include Gitlab::Utils::StrongMemoize
def call def call
return doc if context[:system_note]
@uri_types = {} @uri_types = {}
clear_memoization(:linkable_files) clear_memoization(:linkable_files)
......
...@@ -101,6 +101,13 @@ describe Banzai::Filter::RelativeLinkFilter do ...@@ -101,6 +101,13 @@ describe Banzai::Filter::RelativeLinkFilter do
.to eq "/#{project_path}/blob/#{ref}/doc/api/README.md" .to eq "/#{project_path}/blob/#{ref}/doc/api/README.md"
end end
it 'does not modify relative URLs in system notes' do
path = "#{project_path}/merge_requests/1/diffs"
doc = filter(link(path), system_note: true)
expect(doc.at_css('a')['href']).to eq path
end
it 'ignores absolute URLs with two leading slashes' do it 'ignores absolute URLs with two leading slashes' do
doc = filter(link('//doc/api/README.md')) doc = filter(link('//doc/api/README.md'))
expect(doc.at_css('a')['href']).to eq '//doc/api/README.md' expect(doc.at_css('a')['href']).to eq '//doc/api/README.md'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment