Merge branch 'master' of git.tt-rss.org:fox/tt-rss into wip-config-object

This commit is contained in:
Andrew Dolgov 2021-02-22 23:11:43 +03:00
commit fd5dd27f16
1 changed files with 12 additions and 5 deletions

View File

@ -104,11 +104,11 @@ class jimIcon {
}
// See if we can parse it (might be PNG format here)
$i = @imagecreatefromstring($data);
if ($i) {
imagesavealpha($i, true);
return $i;
if (self::has_parsable_image_type($data)) {
if ($i = @imagecreatefromstring($data)) {
imagesavealpha($i, true);
return $i;
}
}
// Must be a BMP. Parse it ourselves.
@ -267,5 +267,12 @@ class jimIcon {
}
return $img;
}
// Checks whether the data is a type parsable by imagecreatefromstring()
private function has_parsable_image_type($image_data) {
$size = getimagesizefromstring($image_data);
return $size && in_array($size[2],
[IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_GIF, IMAGETYPE_BMP, IMAGETYPE_WBMP, IMAGETYPE_WEBP]);
}
}
?>