mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
Only allow valid snomasks to be set
This commit is contained in:
parent
22f9df388d
commit
5811226760
@ -54,10 +54,16 @@ func (client *Client) applyUserModeChanges(force bool, changes modes.ModeChanges
|
|||||||
}
|
}
|
||||||
var masks []sno.Mask
|
var masks []sno.Mask
|
||||||
if change.Op == modes.Add || change.Op == modes.Remove {
|
if change.Op == modes.Add || change.Op == modes.Remove {
|
||||||
|
var newArg string
|
||||||
for _, char := range change.Arg {
|
for _, char := range change.Arg {
|
||||||
masks = append(masks, sno.Mask(char))
|
mask := sno.Mask(char)
|
||||||
|
if sno.ValidMasks[mask] {
|
||||||
|
masks = append(masks, mask)
|
||||||
|
newArg += string(char)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
change.Arg = newArg
|
||||||
|
}
|
||||||
if change.Op == modes.Add {
|
if change.Op == modes.Add {
|
||||||
client.server.snomasks.AddMasks(client, masks...)
|
client.server.snomasks.AddMasks(client, masks...)
|
||||||
applied = append(applied, change)
|
applied = append(applied, change)
|
||||||
|
@ -35,4 +35,18 @@ var (
|
|||||||
LocalAccounts: "ACCOUNT",
|
LocalAccounts: "ACCOUNT",
|
||||||
LocalXline: "XLINE",
|
LocalXline: "XLINE",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ValidMasks contains the snomasks that we support.
|
||||||
|
ValidMasks = map[Mask]bool{
|
||||||
|
LocalAccouncements: true,
|
||||||
|
LocalConnects: true,
|
||||||
|
LocalChannels: true,
|
||||||
|
LocalKills: true,
|
||||||
|
LocalNicks: true,
|
||||||
|
LocalOpers: true,
|
||||||
|
LocalQuits: true,
|
||||||
|
Stats: true,
|
||||||
|
LocalAccounts: true,
|
||||||
|
LocalXline: true,
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
@ -27,6 +27,11 @@ func (m *SnoManager) AddMasks(client *Client, masks ...sno.Mask) {
|
|||||||
defer m.sendListMutex.Unlock()
|
defer m.sendListMutex.Unlock()
|
||||||
|
|
||||||
for _, mask := range masks {
|
for _, mask := range masks {
|
||||||
|
// confirm mask is valid
|
||||||
|
if !sno.ValidMasks[mask] {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
currentClientList := m.sendLists[mask]
|
currentClientList := m.sendLists[mask]
|
||||||
|
|
||||||
if currentClientList == nil {
|
if currentClientList == nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user