diff options
author | David Lu <david.lu@hotmail.com> | 2016-05-20 14:47:10 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2016-05-20 14:47:10 -0400 |
commit | e81fa3220de51350592e50b2fa3e0dc9425d43f8 (patch) | |
tree | cf9447ba5ab4440f1c641a9d95103ea91e76b873 /model/command.go | |
parent | 4f265522e1ac05ef2c10140019da73e1c4def162 (diff) | |
download | chat-e81fa3220de51350592e50b2fa3e0dc9425d43f8.tar.gz chat-e81fa3220de51350592e50b2fa3e0dc9425d43f8.tar.bz2 chat-e81fa3220de51350592e50b2fa3e0dc9425d43f8.zip |
Added validation for command triggers (#3068)
Diffstat (limited to 'model/command.go')
-rw-r--r-- | model/command.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/model/command.go b/model/command.go index 4d5f7ace9..decb647b7 100644 --- a/model/command.go +++ b/model/command.go @@ -6,11 +6,14 @@ package model import ( "encoding/json" "io" + "strings" ) const ( COMMAND_METHOD_POST = "P" COMMAND_METHOD_GET = "G" + MIN_TRIGGER_LENGTH = 1 + MAX_TRIGGER_LENGTH = 128 ) type Command struct { @@ -99,7 +102,7 @@ func (o *Command) IsValid() *AppError { return NewLocAppError("Command.IsValid", "model.command.is_valid.team_id.app_error", nil, "") } - if len(o.Trigger) == 0 || len(o.Trigger) > 128 { + if len(o.Trigger) < MIN_TRIGGER_LENGTH || len(o.Trigger) > MAX_TRIGGER_LENGTH || strings.Index(o.Trigger, "/") == 0 || strings.Contains(o.Trigger, " ") { return NewLocAppError("Command.IsValid", "model.command.is_valid.trigger.app_error", nil, "") } |