Fix the handling of unhandled image types and of animations (#13904)

* Fix the handling of unhandled image types and of animations

* Avoid warnings
This commit is contained in:
Michael Vogel 2024-02-17 15:46:48 +01:00 committed by GitHub
parent 7d10518e94
commit 08fa51d0bb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 23 additions and 8 deletions

View file

@ -66,7 +66,7 @@ class Image
if (Images::isSupportedMimeType($type)) {
$this->imageType = Images::getImageTypeByMimeType($type);
} elseif (($type == '') || substr($type, 0, 6) != 'image/' || substr($type, 0, 12) != ' application/') {
} elseif (($type == '') || substr($type, 0, 6) == 'image/' || substr($type, 0, 12) == ' application/') {
$this->imageType = IMAGETYPE_WEBP;
DI::logger()->debug('Unhandled image mime type, use WebP instead', ['type' => $type, 'filename' => $filename, 'size' => strlen($data)]);
} else {
@ -100,7 +100,7 @@ class Image
}
if ($this->imageType == IMAGETYPE_GIF) {
$count = preg_match_all("#\x00\x21\xF9\x04.{4}\x00(\x2C|\x21)#s", $data);
$count = @preg_match_all("#\x00\x21\xF9\x04.{4}\x00(\x2C|\x21)#s", $data);
return ($count > 0);
}
@ -115,7 +115,7 @@ class Image
*/
private function isAnimatedWebP(string $data) {
$header_format = 'A4Riff/I1Filesize/A4Webp/A4Vp/A74Chunk';
$header = unpack($header_format, $data);
$header = @unpack($header_format, $data);
if (!isset($header['Riff']) || strtoupper($header['Riff']) !== 'RIFF') {
return false;