From 438d1f048808c582e623438b8c84be5c5d7a8b12 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Thu, 5 Dec 2019 07:52:58 -0500 Subject: [PATCH] fix bad ERR_WASNOSUCHNICK responses --- irc/handlers.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/irc/handlers.go b/irc/handlers.go index 8503534e..dbcc5cb7 100644 --- a/irc/handlers.go +++ b/irc/handlers.go @@ -2773,9 +2773,12 @@ func whowasHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Re nicknames := strings.Split(msg.Params[0], ",") // 0 means "all the entries", as does a negative number - var count uint64 + var count int if len(msg.Params) > 1 { - count, _ = strconv.ParseUint(msg.Params[1], 10, 64) + count, _ = strconv.Atoi(msg.Params[1]) + if count < 0 { + count = 0 + } } //var target string //if len(msg.Params) > 2 { @@ -2783,19 +2786,18 @@ func whowasHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Re //} cnick := client.Nick() for _, nickname := range nicknames { - results := server.whoWas.Find(nickname, int(count)) + if len(nickname) == 0 { + continue + } + results := server.whoWas.Find(nickname, count) if len(results) == 0 { - if len(nickname) > 0 { - rb.Add(nil, server.name, ERR_WASNOSUCHNICK, cnick, nickname, client.t("There was no such nickname")) - } + rb.Add(nil, server.name, ERR_WASNOSUCHNICK, cnick, utils.SafeErrorParam(nickname), client.t("There was no such nickname")) } else { for _, whoWas := range results { rb.Add(nil, server.name, RPL_WHOWASUSER, cnick, whoWas.nick, whoWas.username, whoWas.hostname, "*", whoWas.realname) } } - if len(nickname) > 0 { - rb.Add(nil, server.name, RPL_ENDOFWHOWAS, cnick, nickname, client.t("End of WHOWAS")) - } + rb.Add(nil, server.name, RPL_ENDOFWHOWAS, cnick, utils.SafeErrorParam(nickname), client.t("End of WHOWAS")) } return false }