downstream: check channel name validity on JOIN
Avoid storing garbage in the DB.
This commit is contained in:
parent
58ee475265
commit
6d64c164a7
@ -231,8 +231,15 @@ func updateNetworkAttrs(record *database.Network, attrs irc.Tags, subcommand str
|
|||||||
// - '$' breaks server masks in PRIVMSG/NOTICE
|
// - '$' breaks server masks in PRIVMSG/NOTICE
|
||||||
// - ',' breaks lists
|
// - ',' breaks lists
|
||||||
// - '.' is reserved for server names
|
// - '.' is reserved for server names
|
||||||
|
//
|
||||||
|
// See https://modern.ircdocs.horse/#clients
|
||||||
const illegalNickChars = " :@!*?$,."
|
const illegalNickChars = " :@!*?$,."
|
||||||
|
|
||||||
|
// illegalChanChars is the list of characters forbidden in a channel name.
|
||||||
|
//
|
||||||
|
// See https://modern.ircdocs.horse/#channels
|
||||||
|
const illegalChanChars = " ,\x07"
|
||||||
|
|
||||||
// permanentDownstreamCaps is the list of always-supported downstream
|
// permanentDownstreamCaps is the list of always-supported downstream
|
||||||
// capabilities.
|
// capabilities.
|
||||||
var permanentDownstreamCaps = map[string]string{
|
var permanentDownstreamCaps = map[string]string{
|
||||||
@ -1808,6 +1815,14 @@ func (dc *downstreamConn) handleMessageRegistered(ctx context.Context, msg *irc.
|
|||||||
key = keys[i]
|
key = keys[i]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if name == "" || strings.ContainsAny(name, illegalChanChars) {
|
||||||
|
dc.SendMessage(&irc.Message{
|
||||||
|
Prefix: dc.srv.prefix(),
|
||||||
|
Command: irc.ERR_NOSUCHCHANNEL,
|
||||||
|
Params: []string{name, "Invalid channel name"},
|
||||||
|
})
|
||||||
|
continue
|
||||||
|
}
|
||||||
if !uc.isChannel(name) {
|
if !uc.isChannel(name) {
|
||||||
dc.SendMessage(&irc.Message{
|
dc.SendMessage(&irc.Message{
|
||||||
Prefix: dc.srv.prefix(),
|
Prefix: dc.srv.prefix(),
|
||||||
|
Loading…
Reference in New Issue
Block a user