From 5dded7acadfc248b65502f401b214edcfce9e35d Mon Sep 17 00:00:00 2001 From: Brendon Kozlowski Date: Wed, 10 Jan 2018 12:24:37 -0500 Subject: [PATCH] Update fFile.php Additional detection for unusual (but likely valid) JPEG header formats. https://github.com/flourishlib/flourish-classes/issues/198#issuecomment-355912257 --- fFile.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fFile.php b/fFile.php index a58e398f..525b5ecf 100644 --- a/fFile.php +++ b/fFile.php @@ -182,7 +182,8 @@ static private function determineMimeTypeByContents($content, $extension) $normal_jpeg = $length > 10 && in_array(substr($content, 6, 4), array('JFIF', 'Exif')); $photoshop_jpeg = $length > 24 && $_0_4 == "\xFF\xD8\xFF\xED" && substr($content, 20, 4) == '8BIM'; - if ($normal_jpeg || $photoshop_jpeg) { + $jpeg_prefix = $_0_3 == "\xFF\xD8\xFF"; + if ($normal_jpeg || $photoshop_jpeg || $jpeg_prefix) { return 'image/jpeg'; }