diff options
author | Joram Wilander <jwawilander@gmail.com> | 2015-11-05 10:23:27 -0500 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2015-11-05 10:23:27 -0500 |
commit | d89e970343156c26f609a441e42bfc6bad41fdf8 (patch) | |
tree | 9e3ab5b68b3c42c17f75450971401ab5a4ca1f44 /model/user.go | |
parent | 2c2775e22179942ff30bbabd9cc864012fee5fb5 (diff) | |
parent | c016a88c845ecaa4d219de43243efe07f0103c2d (diff) | |
download | chat-d89e970343156c26f609a441e42bfc6bad41fdf8.tar.gz chat-d89e970343156c26f609a441e42bfc6bad41fdf8.tar.bz2 chat-d89e970343156c26f609a441e42bfc6bad41fdf8.zip |
Merge pull request #1312 from hmhealey/plt592
PLT-592 Correctly measure the length of unicode strings
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) } |