Merge pull request #341 from oragono/restrict-usernames

Restrict idents as other servers do
This commit is contained in:
Shivaram Lingamneni
2019-02-03 15:24:08 -05:00
committed by GitHub
7 changed files with 73 additions and 11 deletions

View File

@@ -2193,10 +2193,15 @@ func userHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Resp
return false
}
err := client.SetNames(msg.Params[0], msg.Params[3])
ident := msg.Params[0]
identLen := server.Limits().IdentLen
if identLen-1 < len(ident) {
ident = ident[:server.Limits().IdentLen-1] // -1 as SetNames adds the ~ at the start for us
}
err := client.SetNames(ident, msg.Params[3])
if err == errInvalidUsername {
rb.Add(nil, "", "ERROR", client.t("Malformed username"))
return true
rb.Add(nil, server.name, ERR_INVALIDUSERNAME, client.t("Malformed username"))
}
return false