Skip to content

Commit 3bb807d

Browse files
committed
upstream: decode ISUPPORT values
We don't really need to decode values for the ISUPPORT tokens we care about, but maybe will in the future, and we re-encode them when sending them to downstream. This resulted in double-encoded NETWORK value for instance.
1 parent 111393a commit 3bb807d

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

upstream.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,7 @@ func (uc *upstreamConn) handleMessage(ctx context.Context, msg *irc.Message) err
998998
token = token[1:]
999999
} else if i := strings.IndexByte(token, '='); i >= 0 {
10001000
parameter = token[:i]
1001-
value = token[i+1:]
1001+
value = xirc.DecodeIsupportValue(token[i+1:])
10021002
hasValue = true
10031003
}
10041004
parameter = strings.ToUpper(parameter)

xirc/genmsg.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,6 @@ func GenerateIsupport(tokens []string) []*irc.Message {
111111
return msgs
112112
}
113113

114-
var isupportEncoder = strings.NewReplacer(" ", "\\x20", "\\", "\\x5C")
115-
116114
func GenerateMOTD(motd string) []*irc.Message {
117115
var msgs []*irc.Message
118116
msgs = append(msgs, &irc.Message{

xirc/xirc.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,12 @@ func (ms *MembershipSet) Remove(membership Membership) {
139139
}
140140
}
141141
}
142+
143+
func DecodeIsupportValue(v string) string {
144+
return isupportDecoder.Replace(v)
145+
}
146+
147+
var (
148+
isupportEncoder = strings.NewReplacer(" ", "\\x20", "\\", "\\x5C")
149+
isupportDecoder = strings.NewReplacer("\\x20", " ", "\\x5C", "\\")
150+
)

0 commit comments

Comments
 (0)