summaryrefslogtreecommitdiff
path: root/lib/jimIcon.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2021-02-24 21:56:52 +0300
committerAndrew Dolgov <[email protected]>2021-02-24 21:56:52 +0300
commit93940d2a9f80d9e1dac49b5eb7db23230d31c5f6 (patch)
tree71016661f6017918d0934eb462bd9552018d557a /lib/jimIcon.php
parent8b022c2bfb356d7dddaf334bc931d6dec77086fb (diff)
parent1adacd057230aea4ede29dab510385bf01cf99a3 (diff)
Merge branch 'master' of git.fakecake.org:fox/tt-rss into weblate-integration
Diffstat (limited to 'lib/jimIcon.php')
-rw-r--r--lib/jimIcon.php17
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]);
+ }
}
?>