From a671ad4707b145eede9c426be47c7cb285a617b5 Mon Sep 17 00:00:00 2001 From: Daniel Lockyer Date: Thu, 16 Jan 2020 14:18:09 +0700 Subject: [PATCH] Handle content requests with overly long filenames no issue - a request for a filename longer than those allowed by the filesystem produced a ENAMETOOLONG error, which would end up becoming a 500 error from Ghost - this catches the error and returns a HTTP 400 Bad Request response --- core/server/adapters/storage/LocalFileStorage.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/server/adapters/storage/LocalFileStorage.js b/core/server/adapters/storage/LocalFileStorage.js index 8ca4293ee5..435bc8bda3 100644 --- a/core/server/adapters/storage/LocalFileStorage.js +++ b/core/server/adapters/storage/LocalFileStorage.js @@ -171,6 +171,10 @@ class LocalFileStore extends StorageBase { })); } + if (err.code === 'ENAMETOOLONG') { + return reject(new common.errors.BadRequestError({err: err})); + } + return reject(new common.errors.GhostError({ err: err, message: common.i18n.t('errors.errors.cannotReadImage', {img: options.path})