MM-36668: Trim large slash commands before logging (#19621)

Automatic Merge
Этот коммит содержится в:
Agniva De Sarker
2022-02-25 13:04:18 +05:30
коммит произвёл GitHub
родитель a640ba7d05
Коммит 95f784a475

Просмотреть файл

@@ -25,6 +25,7 @@ import (
const (
CmdCustomStatusTrigger = "status"
usernameSpecialChars = ".-_"
maxTriggerLen = 512
)
var atMentionRegexp = regexp.MustCompile(`\B@[[:alnum:]][[:alnum:]\.\-_:]*`)
@@ -225,6 +226,10 @@ func (a *App) ExecuteCommand(c *request.Context, args *model.CommandArgs) (*mode
return a.HandleCommandResponse(c, cmd, args, response, true)
}
if len(trigger) > maxTriggerLen {
trigger = trigger[:maxTriggerLen]
trigger += "..."
}
return nil, model.NewAppError("command", "api.command.execute_command.not_found.app_error", map[string]interface{}{"Trigger": trigger}, "", http.StatusNotFound)
}