Mono repo -> Master (#22553)
Combines the following repositories into one: https://github.com/mattermost/mattermost-server https://github.com/mattermost/mattermost-webapp https://github.com/mattermost/focalboard https://github.com/mattermost/mattermost-plugin-playbooks
Этот коммит содержится в:
32
server/channels/app/image.go
Обычный файл
32
server/channels/app/image.go
Обычный файл
@@ -0,0 +1,32 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
package app
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v6/server/channels/app/imaging"
|
||||
)
|
||||
|
||||
func checkImageResolutionLimit(w, h int, maxRes int64) error {
|
||||
// This casting is done to prevent overflow on 32 bit systems (not needed
|
||||
// in 64 bits systems because images can't have more than 32 bits height or
|
||||
// width)
|
||||
imageRes := int64(w) * int64(h)
|
||||
if imageRes > maxRes {
|
||||
return fmt.Errorf("image resolution is too high: %d, max allowed is %d", imageRes, maxRes)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func checkImageLimits(imageData io.Reader, maxRes int64) error {
|
||||
w, h, err := imaging.GetDimensions(imageData)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get image dimensions: %w", err)
|
||||
}
|
||||
|
||||
return checkImageResolutionLimit(w, h, maxRes)
|
||||
}
|
||||
Ссылка в новой задаче
Block a user