Forbid empty and flag-looking network names
This commit is contained in:
parent
3f91cfb8c3
commit
02dac11308
9
user.go
9
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())
|
||||
|
Loading…
Reference in New Issue
Block a user