Skip to content

Commit

Permalink
Fixed issue #14362: Template can throw error with invalid image
Browse files Browse the repository at this point in the history
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 ?
  • Loading branch information
Shnoulle committed Dec 19, 2018
1 parent c3ab580 commit 05aa0a3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions application/core/LSYii_ImageValidator.php
Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion application/core/LS_Twig_Extension.php
Expand Up @@ -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;
Expand Down

0 comments on commit 05aa0a3

Please sign in to comment.