From abfb8442ab3345452894850d4f75d89819f8426e Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Tue, 10 Aug 2021 15:11:11 -0400 Subject: [PATCH] fix handling of +k with an empty key parameter This should be disallowed; `MODE #keytest +k :` should just be an error. --- irc/modes.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/irc/modes.go b/irc/modes.go index c8f01dd9..cbff497d 100644 --- a/irc/modes.go +++ b/irc/modes.go @@ -148,11 +148,7 @@ func ParseDefaultUserModes(rawModes *string) modes.Modes { // #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 + return key != "" && key[0] != ':' && strings.IndexByte(key, ' ') == -1 } // ApplyChannelModeChanges applies a given set of mode changes.