From 05aa0a34692abd29c5d584af411df6b5a601a7ef Mon Sep 17 00:00:00 2001 From: Denis Chenu Date: Thu, 20 Dec 2018 00:18:29 +0100 Subject: [PATCH] Fixed issue #14362: Template can throw error with invalid image Dev: test if file exist before send it to imageValidator Dev: add commment on validateImage function (this can be updated if needed, but not really the task of a image validation) Dev: or did image validation must test if file exist ? --- application/core/LSYii_ImageValidator.php | 5 +++-- application/core/LS_Twig_Extension.php | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/application/core/LSYii_ImageValidator.php b/application/core/LSYii_ImageValidator.php index be268712243..7c50bad4f2c 100644 --- a/application/core/LSYii_ImageValidator.php +++ b/application/core/LSYii_ImageValidator.php @@ -17,9 +17,10 @@ class LSYii_ImageValidator { /** - * A function to validate images + * A function to validate images, + * This don't validate file : must validate if file exist before. * - * @param mixed $path + * @param string $path * @return array */ static function validateImage($path) diff --git a/application/core/LS_Twig_Extension.php b/application/core/LS_Twig_Extension.php index 6c23a7f10b2..e846de8fca1 100644 --- a/application/core/LS_Twig_Extension.php +++ b/application/core/LS_Twig_Extension.php @@ -271,11 +271,14 @@ public static function image($sImagePath, $alt = '', $htmlOptions = array( )) if ($oTemplate) { $sFullPath = $oTemplate->path.$sImagePath; } else { + if(!is_file(Yii::app()->getConfig('rootdir').'/'.$sImagePath)) { + return false; + } $sFullPath = Yii::app()->getConfig('rootdir').'/'.$sImagePath; } // check if this is a true image - $checkImage = LSYii_ImageValidator::validateImage($sFullPath ); + $checkImage = LSYii_ImageValidator::validateImage($sFullPath); if (!$checkImage['check']) { return false;