mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
app/post_metadata: add a check to type casting (#15821)
This commit is contained in:
committed by
GitHub
parent
1bf4373f3f
commit
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()
|
||||
|
||||
Reference in New Issue
Block a user