Description
Environment (please complete the following information):
- PHP IMAP version: 4.2
- PHP Version: 7.4.33
- Type of execution: CLI
Describe the bug
When failing to read Exif Starndar TIFF image data it does return 0 and it crashes because de function getFileInfo expect a string
To Reproduce
Send a attachment like an image that exceeds the name use count.
The used code to fix it:
public function getFileInfo(int $fileinfo_const = FILEINFO_NONE): string
{
if ((FILEINFO_MIME == $fileinfo_const) && (false != $this->mimeType)) {
return $this->mimeType;
}
$finfo = new finfo($fileinfo_const);
$bufferedData = $finfo->buffer($this->getContents());
if (is_bool($bufferedData)){ return ''; } //ADDED LINE SO IT DOES NOT CRASH
return $bufferedData;
}
Expected behavior
When not readed properly just continue.
Screenshots / Outputs
/*
* PHP Warning: finfo::buffer(): Failed identify data 0:JPEG image data, JFIF standard 1.01, aspect ratio, density 72x72, segment length 16, Exif Standard: [TIFF image data, big-endian, direntries=5, orientation=upper-left, xresolution=74, yresolution=82, resolutionunit=2]name use count (30) exceeded in /var/www/html/proyect/vendor/php-imap/php-imap/src/PhpImap/IncomingMailAttachment.php on line 140
* PHP Fatal error: Uncaught TypeError: Return value of PhpImap\IncomingMailAttachment::getFileInfo() must be of the type string, bool returned in /var/www/html/proyect/vendor/php-imap/php-imap/src/PhpImap/IncomingMailAttachment.php:140
*/