diff options
author | Douwe Maan <douwe@selenight.nl> | 2016-01-20 15:26:44 +0100 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2016-01-20 15:26:44 +0100 |
commit | a010db5db243a532cb8d1c2d5ac787e90da0044f (patch) | |
tree | aa7ab255b019bbd5412c34315118616a3a86f81a /lib/gitlab/diff/inline_diff.rb | |
parent | 88bd13851300b98c9d0290cfac5ad1f14673b34d (diff) | |
download | gitlab-ce-a010db5db243a532cb8d1c2d5ac787e90da0044f.tar.gz |
Properly handle HTML entities with inline diffs
Diffstat (limited to 'lib/gitlab/diff/inline_diff.rb')
-rw-r--r-- | lib/gitlab/diff/inline_diff.rb | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/lib/gitlab/diff/inline_diff.rb b/lib/gitlab/diff/inline_diff.rb index e5986fd69e2..b8a61ad6115 100644 --- a/lib/gitlab/diff/inline_diff.rb +++ b/lib/gitlab/diff/inline_diff.rb @@ -16,15 +16,12 @@ module Gitlab old_line = @lines[old_index] new_line = @lines[new_index] - suffixless_old_line = old_line[1..-1] - suffixless_new_line = new_line[1..-1] - # Skip inline diff if empty line was replaced with content - next if suffixless_old_line == "" + next if old_line[1..-1] == "" - # Add one, because this is based on the suffixless version - lcp = longest_common_prefix(suffixless_old_line, suffixless_new_line) + 1 - lcs = longest_common_suffix(suffixless_old_line, suffixless_new_line) + # Add one, because this is based on the prefixless version + lcp = longest_common_prefix(old_line[1..-1], new_line[1..-1]) + 1 + lcs = longest_common_suffix(old_line[lcp..-1], new_line[lcp..-1]) old_diff_range = lcp..(old_line.length - lcs - 1) new_diff_range = lcp..(new_line.length - lcs - 1) |