diff options
author | Robert Speicher <robert@gitlab.com> | 2017-08-22 01:22:37 +0300 |
---|---|---|
committer | Jarka Kadlecova <jarka@gitlab.com> | 2017-08-22 21:17:39 +0300 |
commit | 809ac80a133dfe25332109ca0e6db0e3da1409e3 (patch) | |
tree | a3909d8294564f0ad043d6dc4ce3e927c17e4084 | |
parent | b7712260b4657b2d070dfbc61a46c26657541383 (diff) |
Merge branch 'gitaly-tree-entries-encoding' into 'master'
Correctly encode string params for Gitaly's TreeEntries RPC
Closes #36720
See merge request !13724
-rw-r--r-- | lib/gitlab/gitaly_client/commit_service.rb | 4 | ||||
-rw-r--r-- | spec/lib/gitlab/gitaly_client/commit_service_spec.rb | 14 |
2 files changed, 16 insertions, 2 deletions
diff --git a/lib/gitlab/gitaly_client/commit_service.rb b/lib/gitlab/gitaly_client/commit_service.rb index 3f577ac8530..620e56ee6f1 100644 --- a/lib/gitlab/gitaly_client/commit_service.rb +++ b/lib/gitlab/gitaly_client/commit_service.rb @@ -63,8 +63,8 @@ module Gitlab def tree_entries(repository, revision, path) request = Gitaly::GetTreeEntriesRequest.new( repository: @gitaly_repo, - revision: revision, - path: path.presence || '.' + revision: GitalyClient.encode(revision), + path: path.present? ? GitalyClient.encode(path) : '.' ) response = GitalyClient.call(@repository.storage, :commit_service, :get_tree_entries, request) diff --git a/spec/lib/gitlab/gitaly_client/commit_service_spec.rb b/spec/lib/gitlab/gitaly_client/commit_service_spec.rb index d71e0f84c65..12580ad0112 100644 --- a/spec/lib/gitlab/gitaly_client/commit_service_spec.rb +++ b/spec/lib/gitlab/gitaly_client/commit_service_spec.rb @@ -119,5 +119,19 @@ describe Gitlab::GitalyClient::CommitService do client.tree_entries(repository, revision, path) end + + context 'with UTF-8 params strings' do + let(:revision) { "branch\u011F" } + let(:path) { "foo/\u011F.txt" } + + it 'handles string encodings correctly' do + expect_any_instance_of(Gitaly::CommitService::Stub) + .to receive(:get_tree_entries) + .with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash)) + .and_return([]) + + client.tree_entries(repository, revision, path) + end + end end end |