Changeset 773 in code for trunk/user.go


Ignore:
Timestamp:
Feb 7, 2022, 8:39:39 PM (3 years ago)
Author:
contact
Message:

Forbid empty and flag-looking network names

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/user.go

    r769 r773  
    1010        "net"
    1111        "sort"
     12        "strings"
    1213        "time"
    1314
     
    831832        }
    832833
     834        if record.GetName() == "" {
     835                return fmt.Errorf("network name cannot be empty")
     836        }
     837        if strings.HasPrefix(record.GetName(), "-") {
     838                // Can be mixed up with flags when sending commands to the service
     839                return fmt.Errorf("network name cannot start with a dash character")
     840        }
     841
    833842        for _, net := range u.networks {
    834843                if net.GetName() == record.GetName() && net.ID != record.ID {
Note: See TracChangeset for help on using the changeset viewer.