3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-22 20:09:41 +01:00

Merge pull request #1062 from slingamn/issue1057_ident

fix #1057
This commit is contained in:
Shivaram Lingamneni 2020-05-26 13:21:58 -07:00 committed by GitHub
commit 98151ec7a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View File

@ -2503,12 +2503,18 @@ func userHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Resp
return false
}
err := client.SetNames(msg.Params[0], msg.Params[3], false)
username, realname := msg.Params[0], msg.Params[3]
if len(realname) == 0 {
rb.Add(nil, server.name, ERR_NEEDMOREPARAMS, client.Nick(), client.t("Not enough parameters"))
return false
}
err := client.SetNames(username, realname, false)
if err == errInvalidUsername {
// if client's using a unicode nick or something weird, let's just set 'em up with a stock username instead.
// fixes clients that just use their nick as a username so they can still use the interesting nick
if client.preregNick == msg.Params[0] {
client.SetNames("user", msg.Params[3], false)
if client.preregNick == username {
client.SetNames("user", realname, false)
} else {
rb.Add(nil, server.name, ERR_INVALIDUSERNAME, client.Nick(), client.t("Malformed username"))
}

View File

@ -206,7 +206,9 @@ func (server *Server) tryRegister(c *Client, session *Session) (exiting bool) {
}
// try to complete registration normally
if c.preregNick == "" || !c.HasUsername() || session.capState == caps.NegotiatingState {
// XXX(#1057) username can be filled in by an ident query without the client
// having sent USER: check for both username and realname to ensure they did
if c.preregNick == "" || c.username == "" || c.realname == "" || session.capState == caps.NegotiatingState {
return
}