Fix allow colons and tildes in api.basePath validation

This commit is contained in:
Michael 2026-03-24 17:32:05 +01:00 committed by GitHub
parent 30d5258c75
commit 25ab6f46d0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 1 deletions

View file

@ -58,7 +58,7 @@ const (
)
// Allowed characters in URL following RFC 3986 (https://www.rfc-editor.org/rfc/rfc3986#section-2)
var validBasePath = regexp.MustCompile(`^/[a-zA-Z0-9/_.-]*$`)
var validBasePath = regexp.MustCompile(`^/[a-zA-Z0-9/_.:~-]*$`)
// Configuration is the static configuration.
type Configuration struct {

View file

@ -349,6 +349,16 @@ func TestValidateConfiguration_BasePath(t *testing.T) {
basePath: "/api%2Ftoto",
expectErr: true,
},
{
desc: "valid path with colons",
basePath: "/k8s/clusters/c-abcd0/api/v1/namespaces/my-ns/services/http:traefik:8080/proxy",
expectErr: false,
},
{
desc: "valid path with tilde",
basePath: "/~user/dashboard",
expectErr: false,
},
}
for _, test := range tests {