Fixed string length checks for fields that can contain unicode characters

This commit is contained in:
hmhealey
2015-11-05 09:25:59 -05:00
parent 2c2775e221
commit c016a88c84
6 changed files with 18 additions and 12 deletions

View File

@@ -6,6 +6,7 @@ package model
import (
"encoding/json"
"io"
"unicode/utf8"
)
const (
@@ -52,7 +53,7 @@ func (o *Preference) IsValid() *AppError {
return NewAppError("Preference.IsValid", "Invalid name", "name="+o.Name)
}
if len(o.Value) > 128 {
if utf8.RuneCountInString(o.Value) > 128 {
return NewAppError("Preference.IsValid", "Value is too long", "value="+o.Value)
}