From 600beb5af3e35fd82a2b06995b67629d08fe0fe3 Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Fri, 15 Sep 2017 06:56:08 -0400 Subject: Add some checking of channel ID before sending websocket event (#7431) --- model/utils.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'model/utils.go') diff --git a/model/utils.go b/model/utils.go index 090644ec6..8994a2422 100644 --- a/model/utils.go +++ b/model/utils.go @@ -18,6 +18,7 @@ import ( "strconv" "strings" "time" + "unicode" goi18n "github.com/nicksnyder/go-i18n/i18n" "github.com/pborman/uuid" @@ -492,3 +493,17 @@ func IsValidNumberString(value string) bool { return true } + +func IsValidId(value string) bool { + if len(value) != 26 { + return false + } + + for _, r := range value { + if !unicode.IsLetter(r) && !unicode.IsNumber(r) { + return false + } + } + + return true +} -- cgit v1.2.3-1-g7c22