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

Merge pull request #1936 from slingamn/nick_empty

fix #1933
This commit is contained in:
Shivaram Lingamneni 2022-04-25 18:02:31 -04:00 committed by GitHub
commit 5c7df07d91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View File

@ -117,7 +117,7 @@ func (clients *ClientManager) SetNick(client *Client, session *Session, newNick
}
if useAccountName {
if registered && newNick != accountName && newNick != "" {
if registered && newNick != accountName {
return "", errNickAccountMismatch, false
}
newNick = accountName

View File

@ -2045,14 +2045,22 @@ func namesHandler(server *Server, client *Client, msg ircmsg.Message, rb *Respon
// NICK <nickname>
func nickHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
newNick := msg.Params[0]
if client.registered {
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"))
return false
}
performNickChange(server, client, client, nil, msg.Params[0], rb)
performNickChange(server, client, client, nil, newNick, rb)
} 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
}