Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2016-01-20 20:44:27 +0300
committerDouwe Maan <douwe@selenight.nl>2016-01-20 20:44:27 +0300
commit577f2fb47a7ef57415b78b49d5c746d4e99f6a98 (patch)
treeef621d0febcae9079253b93ae5c319ae94e8d4de /lib/gitlab/diff/highlight.rb
parent26f7d023e6d15f4deab39f74509bd6dddebf6974 (diff)
Save and use actual diff base commit for MR diff highlighting
Diffstat (limited to 'lib/gitlab/diff/highlight.rb')
-rw-r--r--lib/gitlab/diff/highlight.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/gitlab/diff/highlight.rb b/lib/gitlab/diff/highlight.rb
index b6875f07279..fe084a7399a 100644
--- a/lib/gitlab/diff/highlight.rb
+++ b/lib/gitlab/diff/highlight.rb
@@ -31,6 +31,8 @@ module Gitlab
private
def highlight_line(diff_line, index)
+ return html_escape(diff_line.text) unless diff_file.diff_refs
+
line_prefix = diff_line.text.match(/\A([+-])/) ? $1 : ' '
case diff_line.type
@@ -42,7 +44,7 @@ module Gitlab
# Only update text if line is found. This will prevent
# issues with submodules given the line only exists in diff content.
- rich_line ? line_prefix + rich_line : diff_line.text
+ rich_line ? line_prefix + rich_line : html_escape(diff_line.text)
end
def inline_diffs
@@ -63,6 +65,11 @@ module Gitlab
[ref.project.repository, ref.id, path]
end
+
+ def html_escape(str)
+ replacements = { '&' => '&amp;', '>' => '&gt;', '<' => '&lt;', '"' => '&quot;', "'" => '&#39;' }
+ str.gsub(/[&"'><]/, replacements)
+ end
end
end
end