summaryrefslogtreecommitdiffstats
path: root/app/emoji.go
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2018-09-13 13:10:10 -0400
committerCarlos Tadeu Panato Junior <ctadeu@gmail.com>2018-09-13 19:10:10 +0200
commitfd21e53365d504155ab87f9bef60b1ab4faeb38d (patch)
tree90f938af0625c544b3f8cee10efda59a206ccd55 /app/emoji.go
parent7d60bc8cf57b9e47ad4d07bc4bbf61ee2f23c457 (diff)
downloadchat-fd21e53365d504155ab87f9bef60b1ab4faeb38d.tar.gz
chat-fd21e53365d504155ab87f9bef60b1ab4faeb38d.tar.bz2
chat-fd21e53365d504155ab87f9bef60b1ab4faeb38d.zip
MM-12007 Add max dimensions to emoji images (5.3) (#9407)
Diffstat (limited to 'app/emoji.go')
-rw-r--r--app/emoji.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/app/emoji.go b/app/emoji.go
index b07331e65..864dc31bf 100644
--- a/app/emoji.go
+++ b/app/emoji.go
@@ -23,9 +23,11 @@ import (
)
const (
- MaxEmojiFileSize = 1 << 20 // 1 MB
- MaxEmojiWidth = 128
- MaxEmojiHeight = 128
+ MaxEmojiFileSize = 1 << 20 // 1 MB
+ MaxEmojiWidth = 128
+ MaxEmojiHeight = 128
+ MaxEmojiOriginalWidth = 1028
+ MaxEmojiOriginalHeight = 1028
)
func (a *App) CreateEmoji(sessionUserId string, emoji *model.Emoji, multiPartImageData *multipart.Form) (*model.Emoji, *model.AppError) {
@@ -85,6 +87,11 @@ func (a *App) UploadEmojiImage(id string, imageData *multipart.FileHeader) *mode
// make sure the file is an image and is within the required dimensions
if config, _, err := image.DecodeConfig(bytes.NewReader(buf.Bytes())); err != nil {
return model.NewAppError("uploadEmojiImage", "api.emoji.upload.image.app_error", nil, "", http.StatusBadRequest)
+ } else if config.Width > MaxEmojiOriginalWidth || config.Height > MaxEmojiOriginalHeight {
+ return model.NewAppError("uploadEmojiImage", "api.emoji.upload.large_image.too_large.app_error", map[string]interface{}{
+ "MaxWidth": MaxEmojiOriginalWidth,
+ "MaxHeight": MaxEmojiOriginalHeight,
+ }, "", http.StatusBadRequest)
} else if config.Width > MaxEmojiWidth || config.Height > MaxEmojiHeight {
data := buf.Bytes()
newbuf := bytes.NewBuffer(nil)