Commit a564138d authored by Dmitriy Zaporozhets (DZ)'s avatar Dmitriy Zaporozhets (DZ)

Merge branch '207124_skip_highlight_cache_for_unsupported_characters' into 'master'

Skip highlighting cache for diffs with unsupported characters

See merge request gitlab-org/gitlab!69069
parents e4769270 d5a1dd74
......@@ -132,6 +132,8 @@ module Gitlab
diff_file_id,
gzip_compress(highlighted_diff_lines_hash.to_json)
)
rescue Encoding::UndefinedConversionError
nil
end
# HSETs have to have their expiration date manually updated
......
......@@ -185,6 +185,15 @@ RSpec.describe Gitlab::Diff::HighlightCache, :clean_gitlab_redis_cache do
expect { cache.send(:write_to_redis_hash, diff_hash) }
.to change { Gitlab::Redis::Cache.with { |r| r.hgetall(cache_key) } }
end
context 'when diff contains unsupported characters' do
let(:diff_hash) { { 'README' => [{ line_code: nil, rich_text: nil, text: [0xff, 0xfe, 0x0, 0x23].pack("c*"), type: "match", index: 0, old_pos: 17, new_pos: 17 }] } }
it 'does not update the cache' do
expect { cache.send(:write_to_redis_hash, diff_hash) }
.not_to change { Gitlab::Redis::Cache.with { |r| r.hgetall(cache_key) } }
end
end
end
describe '#clear' do
......
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