don't trim spaces before validating the key

This commit is contained in:
Shivaram Lingamneni 2025-06-15 16:10:08 -04:00
parent 1f546bad9c
commit d99eba20d8

View file

@ -5,7 +5,6 @@ import (
"iter" "iter"
"maps" "maps"
"regexp" "regexp"
"strings"
"github.com/ergochat/ergo/irc/caps" "github.com/ergochat/ergo/irc/caps"
"github.com/ergochat/ergo/irc/modes" "github.com/ergochat/ergo/irc/modes"
@ -109,8 +108,6 @@ func syncChannelMetadata(server *Server, rb *ResponseBuffer, channel *Channel) {
var metadataEvilCharsRegexp = regexp.MustCompile("[^A-Za-z0-9_./:-]+") var metadataEvilCharsRegexp = regexp.MustCompile("[^A-Za-z0-9_./:-]+")
func metadataKeyIsEvil(key string) bool { func metadataKeyIsEvil(key string) bool {
key = strings.TrimSpace(key) // just in case
return len(key) == 0 || // key needs to contain stuff return len(key) == 0 || // key needs to contain stuff
key[0] == ':' || // key can't start with a colon key[0] == ':' || // key can't start with a colon
metadataEvilCharsRegexp.MatchString(key) // key can't contain the stuff it can't contain metadataEvilCharsRegexp.MatchString(key) // key can't contain the stuff it can't contain