mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-03 00:15:11 +03: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
@ -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…
Reference in New Issue
Block a user