Prevent image upscaling

This commit is contained in:
Evert Prants 2019-09-07 19:41:32 +03:00
parent 39d3d568e8
commit 94aabcd07e
Signed by: evert
GPG Key ID: 1688DA83D222D0B5

View File

@ -140,12 +140,17 @@ async function uploadImage (identifier, fields, files) {
return bailOut(file, 'Avatars can only have an aspect ratio of 1:1')
}
if (fields.scaleX) {
// Upscaling is not allowed
if ((fields.scaleX != null && fields.scaleX > 1) || (fields.scaleY != null && fields.scaleY > 1)) {
return bailOut(file, 'Image upscaling is not allowed.')
}
if (fields.scaleX != null) {
fields.x *= fields.scaleX
fields.width *= fields.scaleX
}
if (fields.scaleY) {
if (fields.scaleY != null) {
fields.y *= fields.scaleY
fields.height *= fields.scaleY
}