diff options
author | Andrew Dolgov <[email protected]> | 2021-02-22 23:11:43 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2021-02-22 23:11:43 +0300 |
commit | fd5dd27f16fe7da3ca6399501d81022ee2659124 (patch) | |
tree | d667a481fabce8d565040ef1f3d01860fb783ef5 /lib | |
parent | caf30403137075518d17b9f953b3f33bc6c0d6d9 (diff) | |
parent | ac6cea859a4d4b0c01a35502d62ef7a43fce62c7 (diff) |
Merge branch 'master' of git.tt-rss.org:fox/tt-rss into wip-config-object
Diffstat (limited to 'lib')
-rw-r--r-- | lib/jimIcon.php | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/jimIcon.php b/lib/jimIcon.php index f8e533f90..eaa768272 100644 --- a/lib/jimIcon.php +++ b/lib/jimIcon.php @@ -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]); + } } ?> |