Commit c113b700 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'dm-refs-contains-sha-encoding' into 'master'

Fix listing commit branch/tags that contain special characters

Closes #43212

See merge request gitlab-org/gitlab-ce!18023
parents 63923301 39c911ea
---
title: Fix listing commit branch/tags that contain special characters
merge_request:
author:
type: fixed
...@@ -8,6 +8,7 @@ module Gitlab ...@@ -8,6 +8,7 @@ module Gitlab
class Repository class Repository
include Gitlab::Git::RepositoryMirroring include Gitlab::Git::RepositoryMirroring
include Gitlab::Git::Popen include Gitlab::Git::Popen
include Gitlab::EncodingHelper
ALLOWED_OBJECT_DIRECTORIES_VARIABLES = %w[ ALLOWED_OBJECT_DIRECTORIES_VARIABLES = %w[
GIT_OBJECT_DIRECTORY GIT_OBJECT_DIRECTORY
...@@ -1479,7 +1480,7 @@ module Gitlab ...@@ -1479,7 +1480,7 @@ module Gitlab
names.lines.each do |line| names.lines.each do |line|
next unless line.start_with?(refs_prefix) next unless line.start_with?(refs_prefix)
refs << line.rstrip[left_slice_count..-1] refs << encode_utf8(line.rstrip[left_slice_count..-1])
end end
refs refs
......
...@@ -604,17 +604,20 @@ describe Gitlab::Git::Repository, seed_helper: true do ...@@ -604,17 +604,20 @@ describe Gitlab::Git::Repository, seed_helper: true do
shared_examples 'returning the right branches' do shared_examples 'returning the right branches' do
let(:head_id) { repository.rugged.head.target.oid } let(:head_id) { repository.rugged.head.target.oid }
let(:new_branch) { head_id } let(:new_branch) { head_id }
let(:utf8_branch) { 'branch-é' }
before do before do
repository.create_branch(new_branch, 'master') repository.create_branch(new_branch, 'master')
repository.create_branch(utf8_branch, 'master')
end end
after do after do
repository.delete_branch(new_branch) repository.delete_branch(new_branch)
repository.delete_branch(utf8_branch)
end end
it 'displays that branch' do it 'displays that branch' do
expect(repository.branch_names_contains_sha(head_id)).to include('master', new_branch) expect(repository.branch_names_contains_sha(head_id)).to include('master', new_branch, utf8_branch)
end end
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