diff options
author | Mario <mario@mariovavti.com> | 2018-11-25 10:18:26 +0100 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2018-11-25 10:18:26 +0100 |
commit | c7ae3fdc9af6e78ddee63fff4a9938df27d0d39d (patch) | |
tree | ec547ab9507de9a67d48f91fe1345b4746c0ef0f /vendor/blueimp/jquery-file-upload/server/php/UploadHandler.php | |
parent | bc9f2922e0e255e97cb607d099f60c8a81c4736f (diff) | |
download | volse-hubzilla-c7ae3fdc9af6e78ddee63fff4a9938df27d0d39d.tar.gz volse-hubzilla-c7ae3fdc9af6e78ddee63fff4a9938df27d0d39d.tar.bz2 volse-hubzilla-c7ae3fdc9af6e78ddee63fff4a9938df27d0d39d.zip |
update jquery-file-upload and psr-log via composer
Diffstat (limited to 'vendor/blueimp/jquery-file-upload/server/php/UploadHandler.php')
-rw-r--r--[-rwxr-xr-x] | vendor/blueimp/jquery-file-upload/server/php/UploadHandler.php | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/vendor/blueimp/jquery-file-upload/server/php/UploadHandler.php b/vendor/blueimp/jquery-file-upload/server/php/UploadHandler.php index e44004395..5215e4c0f 100755..100644 --- a/vendor/blueimp/jquery-file-upload/server/php/UploadHandler.php +++ b/vendor/blueimp/jquery-file-upload/server/php/UploadHandler.php @@ -38,9 +38,9 @@ class UploadHandler 'image_resize' => 'Failed to resize image' ); - protected const IMAGETYPE_GIF = 1; - protected const IMAGETYPE_JPEG = 2; - protected const IMAGETYPE_PNG = 3; + const IMAGETYPE_GIF = 1; + const IMAGETYPE_JPEG = 2; + const IMAGETYPE_PNG = 3; protected $image_objects = array(); @@ -1047,13 +1047,18 @@ class UploadHandler } protected function create_scaled_image($file_name, $version, $options) { - if ($this->options['image_library'] === 2) { - return $this->imagemagick_create_scaled_image($file_name, $version, $options); - } - if ($this->options['image_library'] && extension_loaded('imagick')) { - return $this->imagick_create_scaled_image($file_name, $version, $options); + try { + if ($this->options['image_library'] === 2) { + return $this->imagemagick_create_scaled_image($file_name, $version, $options); + } + if ($this->options['image_library'] && extension_loaded('imagick')) { + return $this->imagick_create_scaled_image($file_name, $version, $options); + } + return $this->gd_create_scaled_image($file_name, $version, $options); + } catch (\Exception $e) { + error_log($e->getMessage()); + return false; } - return $this->gd_create_scaled_image($file_name, $version, $options); } protected function destroy_image_object($file_path) { @@ -1066,12 +1071,12 @@ class UploadHandler $fp = fopen($file_path, 'r'); $data = fread($fp, 4); fclose($fp); - // GIF: 47 49 46 - if (substr($data, 0, 3) === 'GIF') { + // GIF: 47 49 46 38 + if ($data === 'GIF8') { return self::IMAGETYPE_GIF; } - // JPG: FF D8 - if (bin2hex(substr($data, 0, 2)) === 'ffd8') { + // JPG: FF D8 FF + if (bin2hex(substr($data, 0, 3)) === 'ffd8ff') { return self::IMAGETYPE_JPEG; } // PNG: 89 50 4E 47 @@ -1082,6 +1087,9 @@ class UploadHandler } protected function is_valid_image_file($file_path) { + if (!preg_match('/\.(gif|jpe?g|png)$/i', $file_path)) { + return false; + } return !!$this->imagetype($file_path); } |