Merge pull request #3778 from nextcloud/verify_jpg_files

Test if a file is a valid jpg file
This commit is contained in:
Lukas Reschke 2017-03-10 18:17:51 +01:00 committed by GitHub
commit 42ee401376

View file

@ -562,7 +562,11 @@ class OC_Image implements \OCP\IImage {
break;
case IMAGETYPE_JPEG:
if (imagetypes() & IMG_JPG) {
$this->resource = imagecreatefromjpeg($imagePath);
if (getimagesize($imagePath) !== false) {
$this->resource = imagecreatefromjpeg($imagePath);
} else {
$this->logger->debug('OC_Image->loadFromFile, JPG image not valid: ' . $imagePath, array('app' => 'core'));
}
} else {
$this->logger->debug('OC_Image->loadFromFile, JPG images not supported: ' . $imagePath, array('app' => 'core'));
}