3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-25 05:19:25 +01:00

fix the rest of #1933

`NICK :` pre-registration needs to be special-cased to immediately
send ERR_NONICKNAMEGIVEN (unlike erroneous nonempty nicknames,
which are processed when registration is complete)
This commit is contained in:
Shivaram Lingamneni 2022-04-24 01:39:45 -04:00
parent 7201f14b8b
commit 61fd7a2534

View File

@ -2041,14 +2041,22 @@ func namesHandler(server *Server, client *Client, msg ircmsg.Message, rb *Respon
// NICK <nickname> // NICK <nickname>
func nickHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool { func nickHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
newNick := msg.Params[0]
if client.registered { if client.registered {
if client.account == "" && server.Config().Accounts.NickReservation.ForbidAnonNickChanges { if client.account == "" && server.Config().Accounts.NickReservation.ForbidAnonNickChanges {
rb.Add(nil, server.name, ERR_UNKNOWNERROR, client.Nick(), client.t("You may not change your nickname")) rb.Add(nil, server.name, ERR_UNKNOWNERROR, client.Nick(), client.t("You may not change your nickname"))
return false return false
} }
performNickChange(server, client, client, nil, msg.Params[0], rb) performNickChange(server, client, client, nil, newNick, rb)
} else { } else {
client.preregNick = msg.Params[0] if newNick == "" {
// #1933: this would leave (*Client).preregNick at its zero value of "",
// which is the same condition as NICK not having been sent yet ---
// so we need to send an error immediately
rb.Add(nil, server.name, ERR_NONICKNAMEGIVEN, "*", client.t("No nickname given"))
return false
}
client.preregNick = newNick
} }
return false return false
} }