~emersion/soju-dev

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
2 2

[PATCH] mode parsing: assume '+' by default

Details
Message ID
<20200818092103.54573-1-hubert@hirtzfr.eu>
DKIM signature
pass
Download raw message
Patch: +2 -7
This is common behavior from IRC daemons to assume modestrings such as

    MODE #channel b

to be equivalent to

    MODE #channel +b

soju shouldn't throw an error in such cases.

Sources:
- UnrealIRCd:
  <https://github.com/unrealircd/unrealircd/blob/db798235783a1bdce070e1ab30c663a81b892ca1/src/channel.c#L1168>
- InspIRCd:
  <https://github.com/inspircd/inspircd/blob/aa692dc1039b63deef7886e914ec499abe7facaf/src/mode.cpp#L367>
- oragono:
  <https://github.com/oragono/oragono/blob/385993fb2d5b5f2f3c8e53a5e716048fb6f73b1b/irc/modes/modes.go#L191>
---
 irc.go | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/irc.go b/irc.go
index 4b5f4d3..ffb7f38 100644
--- a/irc.go
+++ b/irc.go
@@ -42,7 +42,7 @@ func (ms *userModes) Del(c byte) {
}

func (ms *userModes) Apply(s string) error {
	var plusMinus byte
	var plusMinus byte = '+'
	for i := 0; i < len(s); i++ {
		switch c := s[i]; c {
		case '+', '-':
@@ -53,8 +53,6 @@ func (ms *userModes) Apply(s string) error {
				ms.Add(c)
			case '-':
				ms.Del(c)
			default:
				return fmt.Errorf("malformed modestring %q: missing plus/minus", s)
			}
		}
	}
@@ -100,7 +98,7 @@ type channelModes map[byte]string
func applyChannelModes(ch *upstreamChannel, modeStr string, arguments []string) (needMarshaling map[int]struct{}, err error) {
	needMarshaling = make(map[int]struct{}, len(arguments))
	nextArgument := 0
	var plusMinus byte
	var plusMinus byte = '+'
outer:
	for i := 0; i < len(modeStr); i++ {
		mode := modeStr[i]
@@ -108,9 +106,6 @@ outer:
			plusMinus = mode
			continue
		}
		if plusMinus != '+' && plusMinus != '-' {
			return nil, fmt.Errorf("malformed modestring %q: missing plus/minus", modeStr)
		}

		for _, membership := range ch.conn.availableMemberships {
			if membership.Mode == mode {
-- 
2.28.0
Details
Message ID
<3Qm2y8hYbcLEYdbdBG3rskb8Fp2Bs3RLv_rATwa9kw_H4h8Wldmv-aTTdoEjS9Rgag5riswNSggkQb1EAFT4jzjQNkKDpDqGQJnIv4Ohewk=@emersion.fr>
In-Reply-To
<20200818092103.54573-1-hubert@hirtzfr.eu> (view parent)
DKIM signature
fail
Download raw message
DKIM signature: fail
Are there clients relying on this behavior? Since this isn't in the
RFC, I'd rather just fix the clients instead…
Details
Message ID
<46482147-5655-103f-fc8b-9e72f58efead@hirtzfr.eu>
In-Reply-To
<3Qm2y8hYbcLEYdbdBG3rskb8Fp2Bs3RLv_rATwa9kw_H4h8Wldmv-aTTdoEjS9Rgag5riswNSggkQb1EAFT4jzjQNkKDpDqGQJnIv4Ohewk=@emersion.fr> (view parent)
DKIM signature
pass
Download raw message
Le 19/08/2020 à 23:56, Simon Ser a écrit :
> Are there clients relying on this behavior? Since this isn't in the
> RFC, I'd rather just fix the clients instead…

err.. this is for users that want to type e.g. `/mode #chan b` to get
the ban list.

Since it doesn't seem soju handles modestrings from downstreams, I guess
this can be closed.
Review patch Export thread (mbox)