Skip to content

Commit

Permalink
client: encode the authority by default (grpc#6318)
Browse files Browse the repository at this point in the history
  • Loading branch information
anicr7 authored Jun 6, 2023
1 parent c9d3ea5 commit 68576b3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion clientconn.go
Original file line number Diff line number Diff line change
Expand Up @@ -1870,7 +1870,12 @@ func (cc *ClientConn) determineAuthority() error {
// the channel authority given the user's dial target. For resolvers
// which don't implement this interface, we will use the endpoint from
// "scheme://authority/endpoint" as the default authority.
cc.authority = endpoint

// Path escape the endpoint to handle use cases where the endpoint
// might not be a valid authority by default.
// For example an endpoint which has multiple paths like
// 'a/b/c', which is not a valid authority by default.
cc.authority = url.PathEscape(endpoint)
}
channelz.Infof(logger, cc.channelzID, "Channel authority set to %q", cc.authority)
return nil
Expand Down
2 changes: 1 addition & 1 deletion test/authority_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ var authorityTests = []authorityTest{
name: "UnixPassthrough",
address: "/tmp/sock.sock",
target: "passthrough:///unix:///tmp/sock.sock",
authority: "unix:///tmp/sock.sock",
authority: "unix:%2F%2F%2Ftmp%2Fsock.sock",
dialTargetWant: "unix:///tmp/sock.sock",
},
{
Expand Down

0 comments on commit 68576b3

Please sign in to comment.