Commit 39c911ea authored by Douwe Maan's avatar Douwe Maan

Fix listing commit branch/tags that contain special characters

parent f56ef206
---
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