mirror of
https://github.com/ergochat/ergo.git
synced 2025-12-20 02:00:11 -08:00
refactor key validation
This commit is contained in:
parent
891e29204e
commit
6ccaeed007
1 changed files with 2 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 validMetadataKeyRegexp = regexp.MustCompile("^[A-Za-z0-9_./-]+$")
|
||||||
|
|
||||||
func metadataKeyIsEvil(key string) bool {
|
func metadataKeyIsEvil(key string) bool {
|
||||||
return len(key) == 0 || // key needs to contain stuff
|
return !validMetadataKeyRegexp.MatchString(key)
|
||||||
metadataEvilCharsRegexp.MatchString(key) // key can't contain the stuff it can't contain
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func metadataCanIEditThisKey(client *Client, targetObj MetadataHaver, key string) bool {
|
func metadataCanIEditThisKey(client *Client, targetObj MetadataHaver, key string) bool {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue