3
0
mirror of https://github.com/ergochat/ergo.git synced 2025-04-12 19:07:57 +02:00

Merge pull request #1835 from slingamn/who.1

fix two WHO bugs
This commit is contained in:
Shivaram Lingamneni 2021-11-16 21:45:40 -05:00 committed by GitHub
commit ac91beabfd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 27 deletions

View File

@ -653,16 +653,15 @@ opers:
# which capabilities this oper has access to # which capabilities this oper has access to
class: "server-admin" class: "server-admin"
# custom whois line # traditionally, operator status is visible to unprivileged users in
# WHO and WHOIS responses. this can be disabled with 'hidden'.
hidden: true
# custom whois line (if `hidden` is enabled, visible only to other operators)
whois-line: is the server administrator whois-line: is the server administrator
# custom hostname # custom hostname (ignored if `hidden` is enabled)
vhost: "staff" #vhost: "staff"
# normally, operator status is visible to unprivileged users in WHO and WHOIS
# responses. this can be disabled with 'hidden'. ('hidden' also causes the
# 'vhost' line above to be ignored.)
hidden: false
# modes are modes to auto-set upon opering-up. uncomment this to automatically # modes are modes to auto-set upon opering-up. uncomment this to automatically
# enable snomasks ("server notification masks" that alert you to server events; # enable snomasks ("server notification masks" that alert you to server events;

View File

@ -3328,12 +3328,15 @@ func (client *Client) rplWhoReply(channel *Channel, target *Client, rb *Response
// WHO <mask> [<filter>%<fields>,<type>] // WHO <mask> [<filter>%<fields>,<type>]
func whoHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool { func whoHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
mask := msg.Params[0] origMask := utils.SafeErrorParam(msg.Params[0])
var err error if origMask != msg.Params[0] {
if mask == "" { rb.Add(nil, server.name, ERR_UNKNOWNERROR, client.Nick(), "WHO", client.t("First param must be a mask or channel"))
rb.Add(nil, server.name, ERR_UNKNOWNERROR, client.nick, "WHO", client.t("First param must be a mask or channel"))
return false return false
} else if mask[0] == '#' { }
mask := origMask
var err error
if mask[0] == '#' {
mask, err = CasefoldChannel(msg.Params[0]) mask, err = CasefoldChannel(msg.Params[0])
} else { } else {
mask, err = CanonicalizeMaskWildcard(mask) mask, err = CanonicalizeMaskWildcard(mask)
@ -3371,12 +3374,18 @@ func whoHandler(server *Server, client *Client, msg ircmsg.Message, rb *Response
fields = fields.Add(field) fields = fields.Add(field)
} }
//TODO(dan): is this used and would I put this param in the Modern doc? // successfully parsed query, ensure we send the success response:
// if not, can we remove it? defer func() {
//var operatorOnly bool rb.Add(nil, server.name, RPL_ENDOFWHO, client.Nick(), origMask, client.t("End of WHO list"))
//if len(msg.Params) > 1 && msg.Params[1] == "o" { }()
// operatorOnly = true
//} // XXX #1730: https://datatracker.ietf.org/doc/html/rfc1459#section-4.5.1
// 'If the "o" parameter is passed only operators are returned according to
// the name mask supplied.'
// see discussion on #1730, we just return no results in this case.
if len(msg.Params) > 1 && msg.Params[1] == "o" {
return false
}
oper := client.Oper() oper := client.Oper()
hasPrivs := oper.HasRoleCapab("sajoin") hasPrivs := oper.HasRoleCapab("sajoin")
@ -3430,7 +3439,6 @@ func whoHandler(server *Server, client *Client, msg ircmsg.Message, rb *Response
} }
} }
rb.Add(nil, server.name, RPL_ENDOFWHO, client.nick, mask, client.t("End of WHO list"))
return false return false
} }

View File

@ -626,17 +626,16 @@ opers:
# which capabilities this oper has access to # which capabilities this oper has access to
class: "server-admin" class: "server-admin"
# custom whois line # traditionally, operator status is visible to unprivileged users in
# WHO and WHOIS responses. this can be disabled with 'hidden'.
hidden: false
# custom whois line (if `hidden` is enabled, visible only to other operators)
whois-line: is the server administrator whois-line: is the server administrator
# custom hostname # custom hostname (ignored if `hidden` is enabled)
vhost: "staff" vhost: "staff"
# normally, operator status is visible to unprivileged users in WHO and WHOIS
# responses. this can be disabled with 'hidden'. ('hidden' also causes the
# 'vhost' line above to be ignored.)
hidden: false
# modes are modes to auto-set upon opering-up. uncomment this to automatically # modes are modes to auto-set upon opering-up. uncomment this to automatically
# enable snomasks ("server notification masks" that alert you to server events; # enable snomasks ("server notification masks" that alert you to server events;
# see `/quote help snomasks` while opered-up for more information): # see `/quote help snomasks` while opered-up for more information):