Don't reveal Grav filesystem path when trying to delete non-existing images

This commit is contained in:
Flavio Copes
2016-01-16 18:30:26 +01:00
parent 1602f2c870
commit f068b48fce

View File

@@ -668,7 +668,7 @@ class AdminController
$filename = !empty($this->post['filename']) ? $this->post['filename'] : null;
if ($filename) {
$targetPath = $page->path().'/'.$filename;
$targetPath = $page->path() . '/' . $filename;
if (file_exists($targetPath)) {
if (unlink($targetPath)) {
@@ -679,18 +679,20 @@ class AdminController
} else {
//Try with responsive images @1x, @2x, @3x
$ext = pathinfo($targetPath, PATHINFO_EXTENSION);
$filename = $page->path() . '/'. basename($targetPath, ".$ext");
$responsiveTargetPath = $filename . '@1x.' . $ext;
$fullPathFilename = $page->path() . '/'. basename($targetPath, ".$ext");
$responsiveTargetPath = $fullPathFilename . '@1x.' . $ext;
$deletedResponsiveImage = false;
if (file_exists($responsiveTargetPath) && unlink($responsiveTargetPath)) {
$deletedResponsiveImage = true;
}
$responsiveTargetPath = $filename . '@2x.' . $ext;
$responsiveTargetPath = $fullPathFilename . '@2x.' . $ext;
if (file_exists($responsiveTargetPath) && unlink($responsiveTargetPath)) {
$deletedResponsiveImage = true;
}
$responsiveTargetPath = $filename . '@3x.' . $ext;
$responsiveTargetPath = $fullPathFilename . '@3x.' . $ext;
if (file_exists($responsiveTargetPath) && unlink($responsiveTargetPath)) {
$deletedResponsiveImage = true;
}