mirror of
https://github.com/ergochat/ergo.git
synced 2025-12-20 02:00:11 -08:00
metadata spec update: disallow colon entirely
This commit is contained in:
parent
a5e435a26b
commit
891e29204e
2 changed files with 3 additions and 3 deletions
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue