cli: validate endpoint using ParseRequestURI (fix #4407) (#4416)

This commit is contained in:
Shraddha Agrawal 2020-04-23 08:40:24 +05:30 committed by GitHub
parent 75d35ac2f6
commit e07761eb33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -161,7 +161,7 @@ func (s *ServerConfig) GetVersionEndpoint() string {
// ParseEndpoint ensures the endpoint is valid.
func (s *ServerConfig) ParseEndpoint() error {
nurl, err := url.Parse(s.Endpoint)
nurl, err := url.ParseRequestURI(s.Endpoint)
if err != nil {
return err
}

View File

@ -2,6 +2,7 @@ package commands
import (
"fmt"
"net/url"
"os"
"path/filepath"
"strings"
@ -183,6 +184,9 @@ func (o *InitOptions) createFiles() error {
}
}
if o.Endpoint != "" {
if _, err := url.ParseRequestURI(o.Endpoint); err != nil {
return errors.Wrap(err, "error validating endpoint URL")
}
config.ServerConfig.Endpoint = o.Endpoint
}
if o.AdminSecret != "" {