From 11bf2e6807641bbb0c450912ff1c7d2e8102b2f6 Mon Sep 17 00:00:00 2001 From: leca Date: Sat, 19 Jul 2025 18:53:50 +0300 Subject: [PATCH] better dimensions check --- Dockerfile | 1 + src/controllers/user.js | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 05a7a53..7aec736 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,3 +11,4 @@ COPY . . EXPOSE 3000 ENTRYPOINT ["node", "./src/index.js"] + diff --git a/src/controllers/user.js b/src/controllers/user.js index ae5fe4c..9f19858 100644 --- a/src/controllers/user.js +++ b/src/controllers/user.js @@ -1,5 +1,3 @@ - - import bcrypt from 'bcrypt'; import jwt from 'jsonwebtoken'; import path from 'path'; @@ -85,7 +83,9 @@ class UserController { } const image = await Jimp.read(tempPath); - if (image.bitmap.width != 64 || image.bitmap.height != 64) { + const allowedWidths = [32, 64, 128]; + const allowedHeights = [32, 64]; + if (!allowedWidths.includes(image.bitmap.width) || !allowedHeights.includes(image.bitmap.height)) { return res.status(400).send('This does not look like a minecraft skin.'); } try {