summaryrefslogtreecommitdiffstats
path: root/model/post.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/post.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/post.go')
-rw-r--r--model/post.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/model/post.go b/model/post.go
index 11f3ad0d5..e0074b348 100644
--- a/model/post.go
+++ b/model/post.go
@@ -6,6 +6,7 @@ package model
import (
"encoding/json"
"io"
+ "unicode/utf8"
)
const (
@@ -94,11 +95,11 @@ func (o *Post) IsValid() *AppError {
return NewAppError("Post.IsValid", "Invalid original id", "")
}
- if len(o.Message) > 4000 {
+ if utf8.RuneCountInString(o.Message) > 4000 {
return NewAppError("Post.IsValid", "Invalid message", "id="+o.Id)
}
- if len(o.Hashtags) > 1000 {
+ if utf8.RuneCountInString(o.Hashtags) > 1000 {
return NewAppError("Post.IsValid", "Invalid hashtags", "id="+o.Id)
}
@@ -106,7 +107,7 @@ func (o *Post) IsValid() *AppError {
return NewAppError("Post.IsValid", "Invalid type", "id="+o.Type)
}
- if len(ArrayToJson(o.Filenames)) > 4000 {
+ if utf8.RuneCountInString(ArrayToJson(o.Filenames)) > 4000 {
return NewAppError("Post.IsValid", "Invalid filenames", "id="+o.Id)
}