mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-04-08 02:52:39 -05:00
Handled missing file extensions for resized image requests
no issue - if a request was sent for an resized image URL that didn't contain a file extension, the code would eventually end up throwing a 500 - this commit checks for this case and returns a 404
This commit is contained in:
parent
c295435b41
commit
a510e075b6
1 changed files with 7 additions and 1 deletions
|
@ -21,8 +21,14 @@ module.exports = function (req, res, next) {
|
|||
return res.redirect(url);
|
||||
};
|
||||
|
||||
// CASE: image manipulator is uncapable of transforming file (e.g. .gif)
|
||||
const requestUrlFileExtension = path.parse(req.url).ext;
|
||||
|
||||
// CASE: no file extension was given
|
||||
if (requestUrlFileExtension === '') {
|
||||
return next();
|
||||
}
|
||||
|
||||
// CASE: image manipulator is uncapable of transforming file (e.g. .gif)
|
||||
if (!image.manipulator.canTransformFileExtension(requestUrlFileExtension)) {
|
||||
return redirectToOriginal();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue