[MM-50080] Limit max length for the name field (#22282)
Этот коммит содержится в:
@@ -68,6 +68,12 @@ func (a *App) executeWorkTemplate(
|
||||
ChannelIDs: []string{},
|
||||
}
|
||||
|
||||
if wtcr.Name != "" {
|
||||
if len(wtcr.Name) > model.ChannelNameMaxLength {
|
||||
return res, model.NewAppError("ExecuteWorkTemplate", "app.worktemplates.execute_work_template.name_too_long", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
}
|
||||
|
||||
contentByType := map[string][]model.WorkTemplateContent{
|
||||
"channel": {},
|
||||
"board": {},
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -228,4 +230,10 @@ func TestExecuteWorkTemplate(t *testing.T) {
|
||||
|
||||
executorMock.AssertExpectations(t)
|
||||
})
|
||||
t.Run("with name too long", func(t *testing.T) {
|
||||
req.Name = strings.Repeat("a", model.ChannelNameMaxLength+1)
|
||||
_, appErr := th.App.executeWorkTemplate(c, req, nil, false)
|
||||
assert.NotNil(t, appErr)
|
||||
assert.Equal(t, http.StatusBadRequest, appErr.StatusCode)
|
||||
})
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user