[MM-50080] Limit max length for the name field (#22282)
Этот коммит содержится в:
@@ -68,6 +68,12 @@ func (a *App) executeWorkTemplate(
|
|||||||
ChannelIDs: []string{},
|
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{
|
contentByType := map[string][]model.WorkTemplateContent{
|
||||||
"channel": {},
|
"channel": {},
|
||||||
"board": {},
|
"board": {},
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
package app
|
package app
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -228,4 +230,10 @@ func TestExecuteWorkTemplate(t *testing.T) {
|
|||||||
|
|
||||||
executorMock.AssertExpectations(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)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7127,6 +7127,10 @@
|
|||||||
"id": "app.worktemplates.execute_work_template.channels.create_error",
|
"id": "app.worktemplates.execute_work_template.channels.create_error",
|
||||||
"translation": "Error while creating a channel."
|
"translation": "Error while creating a channel."
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "app.worktemplates.execute_work_template.name_too_long",
|
||||||
|
"translation": "The name field cannot contain more than 64 characters."
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "app.worktemplates.execute_work_template.playbooks.create_error",
|
"id": "app.worktemplates.execute_work_template.playbooks.create_error",
|
||||||
"translation": "Error while creating a playbook."
|
"translation": "Error while creating a playbook."
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user