diff --git a/user.go b/user.go index 777eb27..a1ff2d9 100644 --- a/user.go +++ b/user.go @@ -9,6 +9,7 @@ import ( "math/big" "net" "sort" + "strings" "time" "gopkg.in/irc.v3" @@ -830,6 +831,14 @@ func (u *user) checkNetwork(record *Network) error { return fmt.Errorf("unknown URL scheme %q", url.Scheme) } + if record.GetName() == "" { + return fmt.Errorf("network name cannot be empty") + } + if strings.HasPrefix(record.GetName(), "-") { + // Can be mixed up with flags when sending commands to the service + return fmt.Errorf("network name cannot start with a dash character") + } + for _, net := range u.networks { if net.GetName() == record.GetName() && net.ID != record.ID { return fmt.Errorf("a network with the name %q already exists", record.GetName())