summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lib/web/imageRouter/index.js10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/web/imageRouter/index.js b/lib/web/imageRouter/index.js
index aa02e9b0..b5c486c3 100644
--- a/lib/web/imageRouter/index.js
+++ b/lib/web/imageRouter/index.js
@@ -20,9 +20,15 @@ imageRouter.post('/uploadimage', function (req, res) {
}
form.parse(req, function (err, fields, files) {
- if (err || !files.image || !files.image.path) {
+ if (err) {
logger.error(`formidable error: ${err}`)
- errors.errorForbidden(res)
+ return errors.errorForbidden(res)
+ } else if (!files.image || !files.image.path) {
+ logger.error(`formidable error: Upload didn't contain file)`)
+ return errors.errorBadRequest(res)
+ } else if (!config.allowedUploadMimeTypes.includes(files.image.type)) {
+ logger.error(`formidable error: MIME-type "${files.image.type}" of uploaded file not allowed, only "${config.allowedUploadMimeTypes.join(', ')}" are allowed)`)
+ return errors.errorBadRequest(res)
} else {
logger.debug(`SERVER received uploadimage: ${JSON.stringify(files.image)}`)