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).
This commit is contained in:
parent
d957493348
commit
e740d952ad
@ -57,6 +57,8 @@ var errAuthFailed = ircError{&irc.Message{
|
|||||||
Params: []string{"*", "Invalid username or password"},
|
Params: []string{"*", "Invalid username or password"},
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
const illegalNickChars = " :/@!*?"
|
||||||
|
|
||||||
// permanentDownstreamCaps is the list of always-supported downstream
|
// permanentDownstreamCaps is the list of always-supported downstream
|
||||||
// capabilities.
|
// capabilities.
|
||||||
var permanentDownstreamCaps = map[string]string{
|
var permanentDownstreamCaps = map[string]string{
|
||||||
@ -330,6 +332,12 @@ func (dc *downstreamConn) handleMessageUnregistered(msg *irc.Message) error {
|
|||||||
if err := parseMessageParams(msg, &nick); err != nil {
|
if err := parseMessageParams(msg, &nick); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if strings.ContainsAny(nick, illegalNickChars) {
|
||||||
|
return ircError{&irc.Message{
|
||||||
|
Command: irc.ERR_ERRONEUSNICKNAME,
|
||||||
|
Params: []string{dc.nick, nick, "contains illegal characters"},
|
||||||
|
}}
|
||||||
|
}
|
||||||
if nick == serviceNick {
|
if nick == serviceNick {
|
||||||
return ircError{&irc.Message{
|
return ircError{&irc.Message{
|
||||||
Command: irc.ERR_NICKNAMEINUSE,
|
Command: irc.ERR_NICKNAMEINUSE,
|
||||||
@ -971,6 +979,13 @@ func (dc *downstreamConn) handleMessageRegistered(msg *irc.Message) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if strings.ContainsAny(nick, illegalNickChars) {
|
||||||
|
return ircError{&irc.Message{
|
||||||
|
Command: irc.ERR_ERRONEUSNICKNAME,
|
||||||
|
Params: []string{dc.nick, nick, "contains illegal characters"},
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
dc.forEachNetwork(func(n *network) {
|
dc.forEachNetwork(func(n *network) {
|
||||||
if err != nil || (upstream != nil && upstream.network != n) {
|
if err != nil || (upstream != nil && upstream.network != n) {
|
||||||
|
Loading…
Reference in New Issue
Block a user