mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-13 07:29:30 +01:00
fix #1021
This commit is contained in:
parent
1ab06949bf
commit
2f9234318c
@ -564,7 +564,12 @@ func (channel *Channel) hasClient(client *Client) bool {
|
|||||||
|
|
||||||
// <mode> <mode params>
|
// <mode> <mode params>
|
||||||
func (channel *Channel) modeStrings(client *Client) (result []string) {
|
func (channel *Channel) modeStrings(client *Client) (result []string) {
|
||||||
isMember := client.HasMode(modes.Operator) || channel.hasClient(client)
|
hasPrivs := client.HasMode(modes.Operator)
|
||||||
|
|
||||||
|
channel.stateMutex.RLock()
|
||||||
|
defer channel.stateMutex.RUnlock()
|
||||||
|
|
||||||
|
isMember := hasPrivs || channel.members[client] != nil
|
||||||
showKey := isMember && (channel.key != "")
|
showKey := isMember && (channel.key != "")
|
||||||
showUserLimit := channel.userLimit > 0
|
showUserLimit := channel.userLimit > 0
|
||||||
|
|
||||||
@ -580,9 +585,6 @@ func (channel *Channel) modeStrings(client *Client) (result []string) {
|
|||||||
|
|
||||||
mods += channel.flags.String()
|
mods += channel.flags.String()
|
||||||
|
|
||||||
channel.stateMutex.RLock()
|
|
||||||
defer channel.stateMutex.RUnlock()
|
|
||||||
|
|
||||||
result = []string{mods}
|
result = []string{mods}
|
||||||
|
|
||||||
// args for flags with args: The order must match above to keep
|
// args for flags with args: The order must match above to keep
|
||||||
|
17
irc/modes.go
17
irc/modes.go
@ -134,6 +134,15 @@ func ParseDefaultUserModes(rawModes *string) modes.ModeChanges {
|
|||||||
return modeChanges
|
return modeChanges
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// #1021: channel key must be valid as a non-final parameter
|
||||||
|
func validateChannelKey(key string) bool {
|
||||||
|
// empty string is valid in this context because it unsets the mode
|
||||||
|
if len(key) == 0 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return key[0] != ':' && strings.IndexByte(key, ' ') == -1
|
||||||
|
}
|
||||||
|
|
||||||
// ApplyChannelModeChanges applies a given set of mode changes.
|
// ApplyChannelModeChanges applies a given set of mode changes.
|
||||||
func (channel *Channel) ApplyChannelModeChanges(client *Client, isSamode bool, changes modes.ModeChanges, rb *ResponseBuffer) (applied modes.ModeChanges) {
|
func (channel *Channel) ApplyChannelModeChanges(client *Client, isSamode bool, changes modes.ModeChanges, rb *ResponseBuffer) (applied modes.ModeChanges) {
|
||||||
// so we only output one warning for each list type when full
|
// so we only output one warning for each list type when full
|
||||||
@ -244,8 +253,12 @@ func (channel *Channel) ApplyChannelModeChanges(client *Client, isSamode bool, c
|
|||||||
case modes.Key:
|
case modes.Key:
|
||||||
switch change.Op {
|
switch change.Op {
|
||||||
case modes.Add:
|
case modes.Add:
|
||||||
channel.setKey(change.Arg)
|
if validateChannelKey(change.Arg) {
|
||||||
applied = append(applied, change)
|
channel.setKey(change.Arg)
|
||||||
|
applied = append(applied, change)
|
||||||
|
} else {
|
||||||
|
rb.Add(nil, client.server.name, ERR_INVALIDMODEPARAM, details.nick, "*", fmt.Sprintf(client.t("Invalid mode %[1]s parameter: %[2]s"), string(change.Mode), change.Arg))
|
||||||
|
}
|
||||||
case modes.Remove:
|
case modes.Remove:
|
||||||
channel.setKey("")
|
channel.setKey("")
|
||||||
applied = append(applied, change)
|
applied = append(applied, change)
|
||||||
|
Loading…
Reference in New Issue
Block a user