xirc: encode tokens in GenerateIsupport
This commit is contained in:
parent
c10d382a7d
commit
fa6f52ed08
@ -1496,7 +1496,7 @@ func (dc *downstreamConn) welcome(ctx context.Context) error {
|
||||
isupport = append(isupport, "BOT=B")
|
||||
}
|
||||
if title := dc.srv.Config().Title; dc.network == nil && title != "" {
|
||||
isupport = append(isupport, "NETWORK="+encodeISUPPORT(title))
|
||||
isupport = append(isupport, "NETWORK="+title)
|
||||
}
|
||||
if dc.network == nil && !dc.isMultiUpstream {
|
||||
isupport = append(isupport, "WHOX")
|
||||
|
6
irc.go
6
irc.go
@ -592,12 +592,6 @@ func generateWHOXReply(prefix *irc.Prefix, nick, fields string, info *whoxInfo)
|
||||
}
|
||||
}
|
||||
|
||||
var isupportEncoder = strings.NewReplacer(" ", "\\x20", "\\", "\\x5C")
|
||||
|
||||
func encodeISUPPORT(s string) string {
|
||||
return isupportEncoder.Replace(s)
|
||||
}
|
||||
|
||||
type capRegistry struct {
|
||||
Available map[string]string
|
||||
Enabled map[string]struct{}
|
||||
|
@ -84,6 +84,7 @@ func (js *joinSorter) Swap(i, j int) {
|
||||
func GenerateIsupport(prefix *irc.Prefix, nick string, tokens []string) []*irc.Message {
|
||||
maxTokens := maxMessageParams - 2 // 2 reserved params: nick + text
|
||||
|
||||
// TODO: take into account maxMessageLength as well
|
||||
var msgs []*irc.Message
|
||||
for len(tokens) > 0 {
|
||||
var msgTokens []string
|
||||
@ -95,16 +96,23 @@ func GenerateIsupport(prefix *irc.Prefix, nick string, tokens []string) []*irc.M
|
||||
tokens = nil
|
||||
}
|
||||
|
||||
encodedTokens := make([]string, len(msgTokens))
|
||||
for i, tok := range msgTokens {
|
||||
encodedTokens[i] = isupportEncoder.Replace(tok)
|
||||
}
|
||||
|
||||
msgs = append(msgs, &irc.Message{
|
||||
Prefix: prefix,
|
||||
Command: irc.RPL_ISUPPORT,
|
||||
Params: append(append([]string{nick}, msgTokens...), "are supported"),
|
||||
Params: append(append([]string{nick}, encodedTokens...), "are supported"),
|
||||
})
|
||||
}
|
||||
|
||||
return msgs
|
||||
}
|
||||
|
||||
var isupportEncoder = strings.NewReplacer(" ", "\\x20", "\\", "\\x5C")
|
||||
|
||||
func GenerateMOTD(prefix *irc.Prefix, nick string, motd string) []*irc.Message {
|
||||
var msgs []*irc.Message
|
||||
msgs = append(msgs, &irc.Message{
|
||||
|
Loading…
Reference in New Issue
Block a user