gitlab-org--gitlab-foss/lib/gitlab/diff/inline_diff_marker.rb
Douwe Maan 98106ec54e
Merge branch '42028-xss-diffs-10-6' into 'security-10-6'
Port of "Fix XSS on commit diff view" for 10-6

See merge request gitlab/gitlabhq!2364
2018-04-05 08:40:05 +02:00

25 lines
650 B
Ruby

module Gitlab
module Diff
class InlineDiffMarker < Gitlab::StringRangeMarker
def initialize(line, rich_line = nil)
super(line, rich_line || line)
end
def mark(line_inline_diffs, mode: nil)
super(line_inline_diffs) do |text, left:, right:|
%{<span class="#{html_class_names(left, right, mode)}">#{text}</span>}
end
end
private
def html_class_names(left, right, mode)
class_names = ["idiff"]
class_names << "left" if left
class_names << "right" if right
class_names << mode if mode
class_names.join(" ")
end
end
end
end