metadata spec update: disallow colon entirely

This commit is contained in:
Shivaram Lingamneni 2025-06-21 22:17:45 -04:00
parent a5e435a26b
commit 891e29204e
2 changed files with 3 additions and 3 deletions

View file

@ -105,11 +105,10 @@ 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 {
return len(key) == 0 || // key needs to contain stuff
key[0] == ':' || // key can't start with a colon
metadataEvilCharsRegexp.MatchString(key) // key can't contain the stuff it can't contain
}

View file

@ -8,9 +8,10 @@ func TestKeyCheck(t *testing.T) {
isEvil bool
}{
{"ImNormal", false},
{"", true},
{":imevil", true},
{"key£with$not%allowed^chars", true},
{"key.that:s_completely/normal-and.fine", false},
{"key.thats_completely/normal-and.fine", false},
}
for _, c := range cases {