diff options
Diffstat (limited to 'model')
-rw-r--r-- | model/emoji.go | 8 | ||||
-rw-r--r-- | model/emoji_test.go | 5 | ||||
-rw-r--r-- | model/user.go | 1 | ||||
-rw-r--r-- | model/user_test.go | 1 |
4 files changed, 8 insertions, 7 deletions
diff --git a/model/emoji.go b/model/emoji.go index 78a266386..f14af89df 100644 --- a/model/emoji.go +++ b/model/emoji.go @@ -41,11 +41,15 @@ func (emoji *Emoji) IsValid() *AppError { return NewAppError("Emoji.IsValid", "model.emoji.update_at.app_error", nil, "id="+emoji.Id, http.StatusBadRequest) } - if len(emoji.CreatorId) != 26 { + if len(emoji.CreatorId) > 26 { return NewAppError("Emoji.IsValid", "model.emoji.user_id.app_error", nil, "", http.StatusBadRequest) } - if len(emoji.Name) == 0 || len(emoji.Name) > EMOJI_NAME_MAX_LENGTH || !IsValidAlphaNumHyphenUnderscore(emoji.Name, false) || inSystemEmoji(emoji.Name) { + return IsValidEmojiName(emoji.Name) +} + +func IsValidEmojiName(name string) *AppError { + if len(name) == 0 || len(name) > EMOJI_NAME_MAX_LENGTH || !IsValidAlphaNumHyphenUnderscore(name, false) || inSystemEmoji(name) { return NewAppError("Emoji.IsValid", "model.emoji.name.app_error", nil, "", http.StatusBadRequest) } diff --git a/model/emoji_test.go b/model/emoji_test.go index 95abe37c6..50d741214 100644 --- a/model/emoji_test.go +++ b/model/emoji_test.go @@ -40,11 +40,6 @@ func TestEmojiIsValid(t *testing.T) { } emoji.UpdateAt = 1234 - emoji.CreatorId = strings.Repeat("1", 25) - if err := emoji.IsValid(); err == nil { - t.Fatal() - } - emoji.CreatorId = strings.Repeat("1", 27) if err := emoji.IsValid(); err == nil { t.Fatal() diff --git a/model/user.go b/model/user.go index c5d6c13b6..e56f3aaed 100644 --- a/model/user.go +++ b/model/user.go @@ -565,6 +565,7 @@ var restrictedUsernames = []string{ "all", "channel", "matterbot", + "system", } func IsValidUsername(s string) bool { diff --git a/model/user_test.go b/model/user_test.go index 645eaadff..a1953a40d 100644 --- a/model/user_test.go +++ b/model/user_test.go @@ -272,6 +272,7 @@ var usernames = []struct { {"spin'punch", false}, {"spin*punch", false}, {"all", false}, + {"system", false}, } func TestValidUsername(t *testing.T) { |