From: Marcel Werk Date: Tue, 25 Apr 2017 15:46:58 +0000 (+0200) Subject: Improved fetching of remote avatars X-Git-Tag: 3.0.5~30 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=eb22407171dd1c77e1584a7a803f130ca1bc282e;p=GitHub%2FWoltLab%2FWCF.git Improved fetching of remote avatars --- diff --git a/wcfsetup/install/files/lib/data/user/avatar/UserAvatarAction.class.php b/wcfsetup/install/files/lib/data/user/avatar/UserAvatarAction.class.php index 860ec04ace..9c89b31702 100644 --- a/wcfsetup/install/files/lib/data/user/avatar/UserAvatarAction.class.php +++ b/wcfsetup/install/files/lib/data/user/avatar/UserAvatarAction.class.php @@ -14,6 +14,7 @@ use wcf\system\user\storage\UserStorageHandler; use wcf\system\WCF; use wcf\util\FileUtil; use wcf\util\HTTPRequest; +use wcf\util\ImageUtil; /** * Executes avatar-related actions. @@ -189,8 +190,21 @@ class UserAvatarAction extends AbstractDatabaseObjectAction { } $tmp = pathinfo($tmp['path']); if (!isset($tmp['basename']) || !isset($tmp['extension'])) { - @unlink($filename); - return; + if (!isset($tmp['basename'])) { + $tmp['basename'] = basename($filename); + } + + if (!isset($tmp['extension'])) { + $imageData = @getimagesize($filename); + if ($imageData !== false) { + $tmp['extension'] = ImageUtil::getExtensionByMimeType($imageData['mime']); + } + } + + if (empty($tmp['extension'])) { + @unlink($filename); + return; + } } $data = [