Changeset 404 in code for trunk


Ignore:
Timestamp:
Aug 20, 2020, 8:00:58 AM (5 years ago)
Author:
hubert
Message:

Reject downstream NICK with illegal characters

This should avoid confusion when mixing up nickname and user name.
Also it avoid breaking downstreams (since '@' and '!' are used for host
masks).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/downstream.go

    r401 r404  
    5757        Params:  []string{"*", "Invalid username or password"},
    5858}}
     59
     60const illegalNickChars = " :/@!*?"
    5961
    6062// permanentDownstreamCaps is the list of always-supported downstream
     
    330332                if err := parseMessageParams(msg, &nick); err != nil {
    331333                        return err
     334                }
     335                if strings.ContainsAny(nick, illegalNickChars) {
     336                        return ircError{&irc.Message{
     337                                Command: irc.ERR_ERRONEUSNICKNAME,
     338                                Params:  []string{dc.nick, nick, "contains illegal characters"},
     339                        }}
    332340                }
    333341                if nick == serviceNick {
     
    972980                }
    973981
     982                if strings.ContainsAny(nick, illegalNickChars) {
     983                        return ircError{&irc.Message{
     984                                Command: irc.ERR_ERRONEUSNICKNAME,
     985                                Params:  []string{dc.nick, nick, "contains illegal characters"},
     986                        }}
     987                }
     988
    974989                var err error
    975990                dc.forEachNetwork(func(n *network) {
Note: See TracChangeset for help on using the changeset viewer.