diff --git a/cmd/setup.go b/cmd/setup.go index 01775efe6..a76112a86 100644 --- a/cmd/setup.go +++ b/cmd/setup.go @@ -7,6 +7,7 @@ import ( "fmt" "net" "net/http" + "regexp" "slices" "strconv" "strings" @@ -68,6 +69,8 @@ var conf = globalConfig{ }, } +var nameRE = regexp.MustCompile(`^[a-zA-Z0-9_.:-]+$`) + type globalConfig struct { Network networkConfig Log string @@ -271,6 +274,10 @@ func configureChargers(static []config.Named, names ...string) error { } func vehicleInstance(cc config.Named) (api.Vehicle, error) { + if !nameRE.MatchString(cc.Name) { + return nil, fmt.Errorf("vehicle name must not contain special characters or spaces: %s", cc.Name) + } + instance, err := vehicle.NewFromConfig(cc.Type, cc.Other) if err != nil { var ce *util.ConfigError