浏览代码

Merge pull request #1835 from slingamn/who.1

fix two WHO bugs
tags/v2.9.0-rc1
Shivaram Lingamneni 2 年前
父节点
当前提交
ac91beabfd
没有帐户链接到提交者的电子邮件
共有 3 个文件被更改,包括 33 次插入27 次删除
  1. 7
    8
      default.yaml
  2. 20
    12
      irc/handlers.go
  3. 6
    7
      traditional.yaml

+ 7
- 8
default.yaml 查看文件

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

+ 20
- 12
irc/handlers.go 查看文件

@@ -3328,12 +3328,15 @@ func (client *Client) rplWhoReply(channel *Channel, target *Client, rb *Response
3328 3328
 
3329 3329
 // WHO <mask> [<filter>%<fields>,<type>]
3330 3330
 func whoHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
3331
-	mask := msg.Params[0]
3332
-	var err error
3333
-	if mask == "" {
3334
-		rb.Add(nil, server.name, ERR_UNKNOWNERROR, client.nick, "WHO", client.t("First param must be a mask or channel"))
3331
+	origMask := utils.SafeErrorParam(msg.Params[0])
3332
+	if origMask != msg.Params[0] {
3333
+		rb.Add(nil, server.name, ERR_UNKNOWNERROR, client.Nick(), "WHO", client.t("First param must be a mask or channel"))
3335 3334
 		return false
3336
-	} else if mask[0] == '#' {
3335
+	}
3336
+
3337
+	mask := origMask
3338
+	var err error
3339
+	if mask[0] == '#' {
3337 3340
 		mask, err = CasefoldChannel(msg.Params[0])
3338 3341
 	} else {
3339 3342
 		mask, err = CanonicalizeMaskWildcard(mask)
@@ -3371,12 +3374,18 @@ func whoHandler(server *Server, client *Client, msg ircmsg.Message, rb *Response
3371 3374
 		fields = fields.Add(field)
3372 3375
 	}
3373 3376
 
3374
-	//TODO(dan): is this used and would I put this param in the Modern doc?
3375
-	// if not, can we remove it?
3376
-	//var operatorOnly bool
3377
-	//if len(msg.Params) > 1 && msg.Params[1] == "o" {
3378
-	//	operatorOnly = true
3379
-	//}
3377
+	// successfully parsed query, ensure we send the success response:
3378
+	defer func() {
3379
+		rb.Add(nil, server.name, RPL_ENDOFWHO, client.Nick(), origMask, client.t("End of WHO list"))
3380
+	}()
3381
+
3382
+	// XXX #1730: https://datatracker.ietf.org/doc/html/rfc1459#section-4.5.1
3383
+	// 'If the "o" parameter is passed only operators are returned according to
3384
+	// the name mask supplied.'
3385
+	// see discussion on #1730, we just return no results in this case.
3386
+	if len(msg.Params) > 1 && msg.Params[1] == "o" {
3387
+		return false
3388
+	}
3380 3389
 
3381 3390
 	oper := client.Oper()
3382 3391
 	hasPrivs := oper.HasRoleCapab("sajoin")
@@ -3430,7 +3439,6 @@ func whoHandler(server *Server, client *Client, msg ircmsg.Message, rb *Response
3430 3439
 		}
3431 3440
 	}
3432 3441
 
3433
-	rb.Add(nil, server.name, RPL_ENDOFWHO, client.nick, mask, client.t("End of WHO list"))
3434 3442
 	return false
3435 3443
 }
3436 3444
 

+ 6
- 7
traditional.yaml 查看文件

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

正在加载...
取消
保存