mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-27 19:19:21 +03:00
This commit is contained in:
parent
0a49027840
commit
5701609857
6 changed files with 34 additions and 17 deletions
|
|
@ -253,7 +253,8 @@ class Http
|
|||
403 => 'Forbidden',
|
||||
404 => 'Not Found',
|
||||
405 => 'Method Not Allowed',
|
||||
416 => 'Requested range not satisfiable'
|
||||
416 => 'Requested range not satisfiable',
|
||||
500 => 'Internal Server Error'
|
||||
);
|
||||
|
||||
$sHeaderText = (0 === \strlen($sCustomStatusText) && isset($aStatus[$iStatus]) ? $aStatus[$iStatus] : $sCustomStatusText);
|
||||
|
|
|
|||
|
|
@ -207,37 +207,32 @@ trait Raw
|
|||
if (!$bDownload)
|
||||
{
|
||||
$bDetectImageOrientation = !!$self->Config()->Get('labs', 'detect_image_exif_orientation', false);
|
||||
if ($bThumbnail)
|
||||
try
|
||||
{
|
||||
try
|
||||
if ($bThumbnail)
|
||||
{
|
||||
$oImage = static::loadImage($rResource, $bDetectImageOrientation, 60);
|
||||
\header('Content-Disposition: inline; '.
|
||||
\trim(\MailSo\Base\Utils::EncodeHeaderUtf8AttributeValue('filename', $sFileName.'_thumb60x60.png')));
|
||||
$oImage->show('png');
|
||||
// $oImage->show('webp'); // Little Britain: "Safari says NO"
|
||||
exit;
|
||||
}
|
||||
catch (\Throwable $oException)
|
||||
{
|
||||
$self->Logger()->WriteExceptionShort($oException);
|
||||
}
|
||||
exit;
|
||||
}
|
||||
else if ($bDetectImageOrientation &&
|
||||
\in_array($sContentType, array('image/png', 'image/jpeg', 'image/jpg', 'image/webp')))
|
||||
{
|
||||
try
|
||||
else if ($bDetectImageOrientation &&
|
||||
\in_array($sContentType, array('image/png', 'image/jpeg', 'image/jpg', 'image/webp')))
|
||||
{
|
||||
$oImage = static::loadImage($rResource, $bDetectImageOrientation);
|
||||
\header('Content-Disposition: inline; '.
|
||||
\trim(\MailSo\Base\Utils::EncodeHeaderUtf8AttributeValue('filename', $sFileName)));
|
||||
$oImage->show();
|
||||
// $oImage->show('webp'); // Little Britain: "Safari says NO"
|
||||
exit;
|
||||
}
|
||||
catch (\Throwable $oException)
|
||||
{
|
||||
$self->Logger()->WriteExceptionShort($oException);
|
||||
}
|
||||
}
|
||||
catch (\Throwable $oException)
|
||||
{
|
||||
$self->Logger()->WriteExceptionShort($oException);
|
||||
\MailSo\Base\Http::StatusHeader(500);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
|
@ -306,6 +301,10 @@ trait Raw
|
|||
$handler = 'SnappyMail\\Image\\'.$handler.'::createFromStream';
|
||||
$oImage = $handler($resource);
|
||||
|
||||
if (!$oImage->valid()) {
|
||||
throw new \Exception('Loading image failed');
|
||||
}
|
||||
|
||||
// rotateImageByOrientation
|
||||
if ($bDetectImageOrientation) {
|
||||
switch ($oImage->getOrientation())
|
||||
|
|
|
|||
|
|
@ -13,4 +13,6 @@ interface Image
|
|||
public function rotate(float $degrees) : bool;
|
||||
|
||||
public function show(?string $format = null) : void;
|
||||
|
||||
public function valid() : bool;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,11 @@ class GD2 implements \SnappyMail\Image
|
|||
return $this->getImageBlob();
|
||||
}
|
||||
|
||||
public function valid() : bool
|
||||
{
|
||||
return $this->img && 0 < \imagesx($this->img);
|
||||
}
|
||||
|
||||
public static function createFromString(string &$data)
|
||||
{
|
||||
if (!($imginfo = \getimagesizefromstring($data))) {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,11 @@ class GMagick extends \Gmagick implements \SnappyMail\Image
|
|||
$this->clear();
|
||||
}
|
||||
|
||||
public function valid() : bool
|
||||
{
|
||||
return 0 < $this->getImageWidth();
|
||||
}
|
||||
|
||||
public static function createFromString(string &$data)
|
||||
{
|
||||
$gmagick = new static();
|
||||
|
|
|
|||
|
|
@ -11,6 +11,11 @@ class IMagick extends \Imagick implements \SnappyMail\Image
|
|||
$this->clear();
|
||||
}
|
||||
|
||||
public function valid() : bool
|
||||
{
|
||||
return 0 < $this->getImageWidth();
|
||||
}
|
||||
|
||||
public static function createFromString(string &$data)
|
||||
{
|
||||
$imagick = new static();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue