Skip to content

Commit

Permalink
xds/bootstrap: escape authority when populating resource name template (
Browse files Browse the repository at this point in the history
  • Loading branch information
menghanl committed Jan 25, 2022
1 parent 231ca3b commit e277174
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion xds/internal/xdsclient/bootstrap/bootstrap.go
Expand Up @@ -25,6 +25,7 @@ import (
"encoding/json"
"fmt"
"io/ioutil"
"net/url"
"strings"

"github.com/golang/protobuf/jsonpb"
Expand Down Expand Up @@ -401,7 +402,7 @@ func NewConfigFromContents(data []byte) (*Config, error) {
// - if set, it must start with "xdstp://<authority_name>/"
// - if not set, it defaults to "xdstp://<authority_name>/envoy.config.listener.v3.Listener/%s"
for name, authority := range config.Authorities {
prefix := fmt.Sprintf("xdstp://%s", name)
prefix := fmt.Sprintf("xdstp://%s", url.PathEscape(name))
if authority.ClientListenerResourceNameTemplate == "" {
authority.ClientListenerResourceNameTemplate = prefix + "/envoy.config.listener.v3.Listener/%s"
continue
Expand Down
6 changes: 5 additions & 1 deletion xds/internal/xdsclient/bootstrap/bootstrap_test.go
Expand Up @@ -862,7 +862,8 @@ func TestNewConfigWithFederation(t *testing.T) {
}],
"client_default_listener_resource_name_template": "xdstp://xds.example.com/envoy.config.listener.v3.Listener/%s",
"authorities": {
"xds.td.com": { }
"xds.td.com": { },
"#.com": { }
}
}`,
// It's OK for an authority to not have servers. The top-level server
Expand Down Expand Up @@ -956,6 +957,9 @@ func TestNewConfigWithFederation(t *testing.T) {
"xds.td.com": {
ClientListenerResourceNameTemplate: "xdstp://xds.td.com/envoy.config.listener.v3.Listener/%s",
},
"#.com": {
ClientListenerResourceNameTemplate: "xdstp://%23.com/envoy.config.listener.v3.Listener/%s",
},
},
},
},
Expand Down

0 comments on commit e277174

Please sign in to comment.