summaryrefslogtreecommitdiffstats
path: root/model/utils.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-09-15 06:56:08 -0400
committerGeorge Goldberg <george@gberg.me>2017-09-15 11:56:08 +0100
commit600beb5af3e35fd82a2b06995b67629d08fe0fe3 (patch)
tree1bb4b6b99420aff52c1efec5631f3094a927c2a9 /model/utils.go
parentb6fb98a43176215f16fc52b64abebde51355e5c1 (diff)
downloadchat-600beb5af3e35fd82a2b06995b67629d08fe0fe3.tar.gz
chat-600beb5af3e35fd82a2b06995b67629d08fe0fe3.tar.bz2
chat-600beb5af3e35fd82a2b06995b67629d08fe0fe3.zip
Add some checking of channel ID before sending websocket event (#7431)
Diffstat (limited to 'model/utils.go')
-rw-r--r--model/utils.go15
1 files changed, 15 insertions, 0 deletions
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
+}