[MM-50827] Detect content-type if missing in response during link metadata generation (#22885)
* Detect content-type if missing in response during link metadata generation * Initialize buffer only when necessary
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
62d758f485
Коммит
b00ca20abe
@@ -2595,6 +2595,18 @@ func TestParseLinkMetadata(t *testing.T) {
|
||||
}, dimensions)
|
||||
})
|
||||
|
||||
t.Run("image with no content-type given", func(t *testing.T) {
|
||||
og, dimensions, err := th.App.parseLinkMetadata(imageURL, makeImageReader(), "")
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Nil(t, og)
|
||||
assert.Equal(t, &model.PostImage{
|
||||
Format: "png",
|
||||
Width: 408,
|
||||
Height: 336,
|
||||
}, dimensions)
|
||||
})
|
||||
|
||||
t.Run("malformed image", func(t *testing.T) {
|
||||
og, dimensions, err := th.App.parseLinkMetadata(imageURL, makeOpenGraphReader(), "image/png")
|
||||
assert.Error(t, err)
|
||||
|
||||
Ссылка в новой задаче
Block a user