Browse Source

Merge pull request #1835 from slingamn/who.1

fix two WHO bugs
tags/v2.9.0-rc1
Shivaram Lingamneni 2 years ago
parent
commit
ac91beabfd
No account linked to committer's email address
3 changed files with 33 additions and 27 deletions
  1. 7
    8
      default.yaml
  2. 20
    12
      irc/handlers.go
  3. 6
    7
      traditional.yaml

+ 7
- 8
default.yaml View File

653
         # which capabilities this oper has access to
653
         # which capabilities this oper has access to
654
         class: "server-admin"
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
         # modes are modes to auto-set upon opering-up. uncomment this to automatically
666
         # modes are modes to auto-set upon opering-up. uncomment this to automatically
668
         # enable snomasks ("server notification masks" that alert you to server events;
667
         # enable snomasks ("server notification masks" that alert you to server events;

+ 20
- 12
irc/handlers.go View File

3328
 
3328
 
3329
 // WHO <mask> [<filter>%<fields>,<type>]
3329
 // WHO <mask> [<filter>%<fields>,<type>]
3330
 func whoHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
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
 		return false
3334
 		return false
3336
-	} else if mask[0] == '#' {
3335
+	}
3336
+
3337
+	mask := origMask
3338
+	var err error
3339
+	if mask[0] == '#' {
3337
 		mask, err = CasefoldChannel(msg.Params[0])
3340
 		mask, err = CasefoldChannel(msg.Params[0])
3338
 	} else {
3341
 	} else {
3339
 		mask, err = CanonicalizeMaskWildcard(mask)
3342
 		mask, err = CanonicalizeMaskWildcard(mask)
3371
 		fields = fields.Add(field)
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
 	oper := client.Oper()
3390
 	oper := client.Oper()
3382
 	hasPrivs := oper.HasRoleCapab("sajoin")
3391
 	hasPrivs := oper.HasRoleCapab("sajoin")
3430
 		}
3439
 		}
3431
 	}
3440
 	}
3432
 
3441
 
3433
-	rb.Add(nil, server.name, RPL_ENDOFWHO, client.nick, mask, client.t("End of WHO list"))
3434
 	return false
3442
 	return false
3435
 }
3443
 }
3436
 
3444
 

+ 6
- 7
traditional.yaml View File

626
         # which capabilities this oper has access to
626
         # which capabilities this oper has access to
627
         class: "server-admin"
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
         whois-line: is the server administrator
634
         whois-line: is the server administrator
631
 
635
 
632
-        # custom hostname
636
+        # custom hostname (ignored if `hidden` is enabled)
633
         vhost: "staff"
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
         # modes are modes to auto-set upon opering-up. uncomment this to automatically
639
         # modes are modes to auto-set upon opering-up. uncomment this to automatically
641
         # enable snomasks ("server notification masks" that alert you to server events;
640
         # enable snomasks ("server notification masks" that alert you to server events;
642
         # see `/quote help snomasks` while opered-up for more information):
641
         # see `/quote help snomasks` while opered-up for more information):

Loading…
Cancel
Save