MM-36893 : Specially crafted message request crashes the webapp for users who view the message (#18835)
* strip away delete * added tests
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
8c4e6a85b3
Коммит
bf589c2995
@@ -43,6 +43,9 @@ func createPost(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Strip away delete_at if passed
|
||||||
|
post.DeleteAt = 0
|
||||||
|
|
||||||
post.UserId = c.AppContext.Session().UserId
|
post.UserId = c.AppContext.Session().UserId
|
||||||
|
|
||||||
auditRec := c.MakeAuditRecord("createPost", audit.Fail)
|
auditRec := c.MakeAuditRecord("createPost", audit.Fail)
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ func TestCreatePost(t *testing.T) {
|
|||||||
defer th.TearDown()
|
defer th.TearDown()
|
||||||
client := th.Client
|
client := th.Client
|
||||||
|
|
||||||
post := &model.Post{ChannelId: th.BasicChannel.Id, Message: "#hashtag a" + model.NewId() + "a", Props: model.StringInterface{model.PropsAddChannelMember: "no good"}}
|
post := &model.Post{ChannelId: th.BasicChannel.Id, Message: "#hashtag a" + model.NewId() + "a", Props: model.StringInterface{model.PropsAddChannelMember: "no good"}, DeleteAt: 101}
|
||||||
|
|
||||||
rpost, resp, err2 := client.CreatePost(post)
|
rpost, resp, err2 := client.CreatePost(post)
|
||||||
require.NoError(t, err2)
|
require.NoError(t, err2)
|
||||||
@@ -46,6 +46,7 @@ func TestCreatePost(t *testing.T) {
|
|||||||
require.Empty(t, rpost.FileIds)
|
require.Empty(t, rpost.FileIds)
|
||||||
require.Equal(t, 0, int(rpost.EditAt), "newly created post shouldn't have EditAt set")
|
require.Equal(t, 0, int(rpost.EditAt), "newly created post shouldn't have EditAt set")
|
||||||
require.Nil(t, rpost.GetProp(model.PropsAddChannelMember), "newly created post shouldn't have Props['add_channel_member'] set")
|
require.Nil(t, rpost.GetProp(model.PropsAddChannelMember), "newly created post shouldn't have Props['add_channel_member'] set")
|
||||||
|
require.Equal(t, 0, int(rpost.DeleteAt), "newly created post shouldn't have DeleteAt set")
|
||||||
|
|
||||||
post.RootId = rpost.Id
|
post.RootId = rpost.Id
|
||||||
_, _, err2 = client.CreatePost(post)
|
_, _, err2 = client.CreatePost(post)
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user