diff options
author | =Corey Hulen <corey@hulen.com> | 2015-10-26 22:11:42 -0700 |
---|---|---|
committer | =Corey Hulen <corey@hulen.com> | 2015-10-26 22:11:42 -0700 |
commit | aec99ceb9d47d6354ac5a96bbc290126b55d30f5 (patch) | |
tree | ecb72b0d51f6edc7341ac5bef0a4f61583f81dde /api/user.go | |
parent | e750a8fd361ef6dfce557530a10aaf5ce5a7f37e (diff) | |
parent | 28847c6b4b864d747bbfdf5c53354dcb24e5f895 (diff) | |
download | chat-aec99ceb9d47d6354ac5a96bbc290126b55d30f5.tar.gz chat-aec99ceb9d47d6354ac5a96bbc290126b55d30f5.tar.bz2 chat-aec99ceb9d47d6354ac5a96bbc290126b55d30f5.zip |
Merge branch 'master' into PLT-25
Diffstat (limited to 'api/user.go')
-rw-r--r-- | api/user.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/api/user.go b/api/user.go index 3071e1b26..3796a50ee 100644 --- a/api/user.go +++ b/api/user.go @@ -814,6 +814,7 @@ func getProfileImage(c *Context, w http.ResponseWriter, r *http.Request) { w.Header().Set("Cache-Control", "max-age=86400, public") // 24 hrs } + w.Header().Set("Content-Type", "image/png") w.Write(img) } } @@ -854,6 +855,18 @@ func uploadProfileImage(c *Context, w http.ResponseWriter, r *http.Request) { return } + // Decode image config first to check dimensions before loading the whole thing into memory later on + config, _, err := image.DecodeConfig(file) + if err != nil { + c.Err = model.NewAppError("uploadProfileFile", "Could not decode profile image config.", err.Error()) + return + } else if config.Width*config.Height > MaxImageSize { + c.Err = model.NewAppError("uploadProfileFile", "Unable to upload profile image. File is too large.", err.Error()) + return + } + + file.Seek(0, 0) + // Decode image into Image object img, _, err := image.Decode(file) if err != nil { |