From c78e35c36f06df50b35ab1a55a8e52165b705ec7 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Thu, 4 Jun 2015 12:19:39 -0500 Subject: [PATCH] Allow jpe, jfif and jif image extensions --- main/auth/profile.php | 4 ++-- main/inc/lib/main_api.lib.php | 3 ++- main/inc/lib/usermanager.lib.php | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/main/auth/profile.php b/main/auth/profile.php index 32d65c3d47..139d9cdc2a 100755 --- a/main/auth/profile.php +++ b/main/auth/profile.php @@ -216,8 +216,8 @@ if (is_profile_editable() && api_get_setting('profile', 'picture') == 'true') { if (!empty($user_data['picture_uri'])) { $form->addElement('checkbox', 'remove_picture', null, get_lang('DelImage')); } - $allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif'); - $form->addRule('picture', get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types); + $allowed_picture_types = api_get_supported_image_extensions(); + $form->addRule('picture', get_lang('OnlyImagesAllowed').' ('.implode(', ', $allowed_picture_types).')', 'filetype', $allowed_picture_types); } // LANGUAGE diff --git a/main/inc/lib/main_api.lib.php b/main/inc/lib/main_api.lib.php index e7199a14b7..d8d57f44d6 100755 --- a/main/inc/lib/main_api.lib.php +++ b/main/inc/lib/main_api.lib.php @@ -7478,7 +7478,8 @@ function api_get_configuration_value($variable) */ function api_get_supported_image_extensions() { - $supportedImageExtensions = array('jpg', 'jpeg', 'png', 'gif', 'svg'); + // jpg can also be called jpeg, jpe, jfif and jif. See https://en.wikipedia.org/wiki/JPEG#JPEG_filename_extensions + $supportedImageExtensions = array('jpg', 'jpeg', 'png', 'gif', 'svg', 'jpe', 'jfif', 'jif'); if (version_compare(PHP_VERSION, '5.5.0', '>=')) { array_push($supportedImageExtensions, 'webp'); } diff --git a/main/inc/lib/usermanager.lib.php b/main/inc/lib/usermanager.lib.php index 3466dee90e..66b1d3142b 100755 --- a/main/inc/lib/usermanager.lib.php +++ b/main/inc/lib/usermanager.lib.php @@ -1265,7 +1265,7 @@ class UserManager } // Validation 2. - $allowed_types = array('jpg', 'jpeg', 'png', 'gif'); + $allowed_types = api_get_supported_image_extensions(); $file = str_replace('\\', '/', $file); $filename = (($pos = strrpos($file, '/')) !== false) ? substr($file, $pos + 1) : $file; $extension = strtolower(substr(strrchr($filename, '.'), 1));