diff options
author | hmhealey <harrisonmhealey@gmail.com> | 2015-11-05 09:25:59 -0500 |
---|---|---|
committer | hmhealey <harrisonmhealey@gmail.com> | 2015-11-05 09:35:35 -0500 |
commit | c016a88c845ecaa4d219de43243efe07f0103c2d (patch) | |
tree | 9e3ab5b68b3c42c17f75450971401ab5a4ca1f44 /model/user.go | |
parent | 2c2775e22179942ff30bbabd9cc864012fee5fb5 (diff) | |
download | chat-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/user.go')
-rw-r--r-- | model/user.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/model/user.go b/model/user.go index 15016f8dc..871d1bf2d 100644 --- a/model/user.go +++ b/model/user.go @@ -10,6 +10,7 @@ import ( "io" "regexp" "strings" + "unicode/utf8" ) const ( @@ -80,15 +81,15 @@ func (u *User) IsValid() *AppError { return NewAppError("User.IsValid", "Invalid email", "user_id="+u.Id) } - if len(u.Nickname) > 64 { + if utf8.RuneCountInString(u.Nickname) > 64 { return NewAppError("User.IsValid", "Invalid nickname", "user_id="+u.Id) } - if len(u.FirstName) > 64 { + if utf8.RuneCountInString(u.FirstName) > 64 { return NewAppError("User.IsValid", "Invalid first name", "user_id="+u.Id) } - if len(u.LastName) > 64 { + if utf8.RuneCountInString(u.LastName) > 64 { return NewAppError("User.IsValid", "Invalid last name", "user_id="+u.Id) } |