summaryrefslogtreecommitdiffstats
path: root/model/channel.go
diff options
context:
space:
mode:
authorhmhealey <harrisonmhealey@gmail.com>2015-11-05 09:25:59 -0500
committerhmhealey <harrisonmhealey@gmail.com>2015-11-05 09:35:35 -0500
commitc016a88c845ecaa4d219de43243efe07f0103c2d (patch)
tree9e3ab5b68b3c42c17f75450971401ab5a4ca1f44 /model/channel.go
parent2c2775e22179942ff30bbabd9cc864012fee5fb5 (diff)
downloadchat-c016a88c845ecaa4d219de43243efe07f0103c2d.tar.gz
chat-c016a88c845ecaa4d219de43243efe07f0103c2d.tar.bz2
chat-c016a88c845ecaa4d219de43243efe07f0103c2d.zip
Fixed string length checks for fields that can contain unicode characters
Diffstat (limited to 'model/channel.go')
-rw-r--r--model/channel.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/model/channel.go b/model/channel.go
index ac54a7e44..0ce09f4bc 100644
--- a/model/channel.go
+++ b/model/channel.go
@@ -6,6 +6,7 @@ package model
import (
"encoding/json"
"io"
+ "unicode/utf8"
)
const (
@@ -74,7 +75,7 @@ func (o *Channel) IsValid() *AppError {
return NewAppError("Channel.IsValid", "Update at must be a valid time", "id="+o.Id)
}
- if len(o.DisplayName) > 64 {
+ if utf8.RuneCountInString(o.DisplayName) > 64 {
return NewAppError("Channel.IsValid", "Invalid display name", "id="+o.Id)
}
@@ -90,11 +91,11 @@ func (o *Channel) IsValid() *AppError {
return NewAppError("Channel.IsValid", "Invalid type", "id="+o.Id)
}
- if len(o.Header) > 1024 {
+ if utf8.RuneCountInString(o.Header) > 1024 {
return NewAppError("Channel.IsValid", "Invalid header", "id="+o.Id)
}
- if len(o.Purpose) > 128 {
+ if utf8.RuneCountInString(o.Purpose) > 128 {
return NewAppError("Channel.IsValid", "Invalid purpose", "id="+o.Id)
}