Commit d3b89a40 authored by Douwe Maan's avatar Douwe Maan

Merge branch...

Merge branch '37576-renamed-files-have-escaped-html-for-the-inline-diff-in-the-header' into 'master'

Resolve "Renamed files have escaped HTML for the inline diff in the header"

Closes #37576

See merge request gitlab-org/gitlab-ce!14121
parents d3fb1da1 46e4e8f4
---
title: Fix the diff file header from being html escaped for renamed files.
merge_request: 14121
author:
type: fixed
......@@ -2,9 +2,10 @@ module Gitlab
module Diff
class InlineDiffMarker < Gitlab::StringRangeMarker
def mark(line_inline_diffs, mode: nil)
super(line_inline_diffs) do |text, left:, right:|
mark = super(line_inline_diffs) do |text, left:, right:|
%{<span class="#{html_class_names(left, right, mode)}">#{text}</span>}
end
mark.html_safe
end
private
......
......@@ -108,6 +108,19 @@ feature 'Diff file viewer', :js do
end
end
context 'renamed file' do
before do
visit_commit('6907208d755b60ebeacb2e9dfea74c92c3449a1f')
end
it 'shows the filename with diff highlight' do
within('.file-header-content') do
expect(page).to have_css('.idiff.left.right.deletion')
expect(page).to have_content('files/js/commit.coffee')
end
end
end
context 'binary file that appears to be text in the first 1024 bytes' do
before do
# The file we're visiting is smaller than 10 KB and we want it collapsed
......
......@@ -136,9 +136,9 @@ describe DiffHelper do
marked_old_line, marked_new_line = mark_inline_diffs(old_line, new_line)
expect(marked_old_line).to eq(%q{abc <span class="idiff left right deletion">'def'</span>})
expect(marked_old_line).not_to be_html_safe
expect(marked_old_line).to be_html_safe
expect(marked_new_line).to eq(%q{abc <span class="idiff left right addition">"def"</span>})
expect(marked_new_line).not_to be_html_safe
expect(marked_new_line).to be_html_safe
end
end
......
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