From: Matthias Schmidt Date: Mon, 5 Sep 2016 18:59:15 +0000 (+0200) Subject: Do not rely on mime type for image validation X-Git-Tag: 3.0.0_Beta_1~284 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=63190ba3dce3c296d734f97be52310cfae310cba;p=GitHub%2FWoltLab%2FWCF.git Do not rely on mime type for image validation … for those systems without `\finfo`. --- diff --git a/wcfsetup/install/files/lib/system/upload/MediaUploadFileValidationStrategy.class.php b/wcfsetup/install/files/lib/system/upload/MediaUploadFileValidationStrategy.class.php index 2096fff0cc..f8fceac8d3 100644 --- a/wcfsetup/install/files/lib/system/upload/MediaUploadFileValidationStrategy.class.php +++ b/wcfsetup/install/files/lib/system/upload/MediaUploadFileValidationStrategy.class.php @@ -35,7 +35,7 @@ class MediaUploadFileValidationStrategy implements IUploadFileValidationStrategy return false; } - if (!empty($this->fileTypeFilters['isImage']) && ($uploadFile->getImageData() === null || !preg_match('~^image/(gif|jpe?g|png)$~i', $uploadFile->getMimeType()))) { + if (!empty($this->fileTypeFilters['isImage']) && $uploadFile->getImageData() === null) { $uploadFile->setValidationErrorType('noImage'); return false; } diff --git a/wcfsetup/install/files/lib/system/upload/UploadFile.class.php b/wcfsetup/install/files/lib/system/upload/UploadFile.class.php index 55ace04329..689bdb7d6b 100644 --- a/wcfsetup/install/files/lib/system/upload/UploadFile.class.php +++ b/wcfsetup/install/files/lib/system/upload/UploadFile.class.php @@ -165,14 +165,12 @@ class UploadFile { * @return array|null */ public function getImageData() { - if (strpos($this->getMimeType(), 'image/') == 0) { - if (($imageData = @getimagesize($this->getLocation())) !== false) { - return [ - 'width' => $imageData[0], - 'height' => $imageData[1], - 'mimeType' => $imageData['mime'] - ]; - } + if (($imageData = @getimagesize($this->getLocation())) !== false) { + return [ + 'width' => $imageData[0], + 'height' => $imageData[1], + 'mimeType' => $imageData['mime'] + ]; } return null;