diff --git a/server/.golangci.yml b/server/.golangci.yml index 5b0b2f78094..1b5f7ffa284 100644 --- a/server/.golangci.yml +++ b/server/.golangci.yml @@ -92,7 +92,6 @@ issues: channels/app/export_test.go|\ channels/app/file.go|\ channels/app/file_bench_test.go|\ - channels/app/file_info.go|\ channels/app/file_test.go|\ channels/app/helper_test.go|\ channels/app/import_functions.go|\ diff --git a/server/channels/app/file_info.go b/server/channels/app/file_info.go index 068bf8a45a7..f13d6442d75 100644 --- a/server/channels/app/file_info.go +++ b/server/channels/app/file_info.go @@ -40,7 +40,9 @@ func getInfoForBytes(name string, data io.ReadSeeker, size int) (*model.FileInfo if info.MimeType == "image/gif" { // Just show the gif itself instead of a preview image for animated gifs - data.Seek(0, io.SeekStart) + if _, err := data.Seek(0, io.SeekStart); err != nil { + return info, model.NewAppError("getInfoForBytes", "app.file_info.seek.gif.app_error", nil, "", http.StatusBadRequest).Wrap(err) + } frameCount, err := imgutils.CountGIFFrames(data) if err != nil { // Still return the rest of the info even though it doesn't appear to be an actual gif diff --git a/server/i18n/en.json b/server/i18n/en.json index b8bfab1bf46..e490429c07e 100644 --- a/server/i18n/en.json +++ b/server/i18n/en.json @@ -5162,6 +5162,10 @@ "id": "app.file_info.save.app_error", "translation": "Unable to save the file info." }, + { + "id": "app.file_info.seek.gif.app_error", + "translation": "Unable to seek to the beginning of the GIF data." + }, { "id": "app.file_info.set_searchable_content.app_error", "translation": "Unable to set the searchable content of the file."