app/post_metadata: add a check to type casting (#15821)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
1bf4373f3f
Коммит
26e3bc0a24
@@ -71,7 +71,11 @@ func (a *App) OverrideIconURLIfEmoji(post *model.Post) {
|
||||
if !ok || prop == nil {
|
||||
return
|
||||
}
|
||||
emojiName := prop.(string)
|
||||
|
||||
emojiName, ok := prop.(string)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
if !*a.Config().ServiceSettings.EnablePostIconOverride || emojiName == "" {
|
||||
return
|
||||
|
||||
@@ -358,6 +358,25 @@ func TestPreparePostForClient(t *testing.T) {
|
||||
})
|
||||
})
|
||||
|
||||
t.Run("post props has invalid fields", func(t *testing.T) {
|
||||
th := setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
post, err := th.App.CreatePost(&model.Post{
|
||||
UserId: th.BasicUser.Id,
|
||||
ChannelId: th.BasicChannel.Id,
|
||||
Message: "some post",
|
||||
}, th.BasicChannel, false, true)
|
||||
require.Nil(t, err)
|
||||
|
||||
// this value expected to be a string
|
||||
post.AddProp(model.POST_PROPS_OVERRIDE_ICON_EMOJI, true)
|
||||
|
||||
require.NotPanics(t, func() {
|
||||
_ = th.App.PreparePostForClient(post, false, false)
|
||||
})
|
||||
})
|
||||
|
||||
t.Run("proxy linked images", func(t *testing.T) {
|
||||
th := setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
Ссылка в новой задаче
Block a user