summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2017-08-21 22:22:37 +0000
committerRobert Speicher <robert@gitlab.com>2017-08-21 22:22:37 +0000
commit539ed0a6375d5bb6d734e688b801373e4b8006f9 (patch)
tree75e806b2c6a52eef6bfd14cd8a6260517d7beeb4
parentce57827268e30fc787fa8d7fe18231b0bb6298b7 (diff)
parentb7ebb447d7a0f8e65c791d4f7af6e042b72ff644 (diff)
downloadgitlab-ce-539ed0a6375d5bb6d734e688b801373e4b8006f9.tar.gz
Correctly encode string params for Gitaly's TreeEntries RPC Closes #36720 See merge request !13724
-rw-r--r--lib/gitlab/gitaly_client/commit_service.rb4
-rw-r--r--spec/lib/gitlab/gitaly_client/commit_service_spec.rb14
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 b36e81278d6..2d58fb0186e 100644
--- a/lib/gitlab/gitaly_client/commit_service.rb
+++ b/lib/gitlab/gitaly_client/commit_service.rb
@@ -80,8 +80,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 7fe698fcb18..2eaf4222964 100644
--- a/spec/lib/gitlab/gitaly_client/commit_service_spec.rb
+++ b/spec/lib/gitlab/gitaly_client/commit_service_spec.rb
@@ -111,6 +111,20 @@ 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
describe '#find_commit' do