aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2019-01-02 17:49:21 +0100
committerMario Vavti <mario@mariovavti.com>2019-01-02 17:49:21 +0100
commitf3f106c21f81cdb297a9f76765df3686eec1d95d (patch)
treed3018415ddc6970982a9b367bd149e9813bb8f66
parent37d7d18bb7b1e3bcadbb11c43a761d6953c2dc55 (diff)
downloadvolse-hubzilla-f3f106c21f81cdb297a9f76765df3686eec1d95d.tar.gz
volse-hubzilla-f3f106c21f81cdb297a9f76765df3686eec1d95d.tar.bz2
volse-hubzilla-f3f106c21f81cdb297a9f76765df3686eec1d95d.zip
check suppported type if we get content type from header
-rw-r--r--include/photo/photo_driver.php11
1 files changed, 7 insertions, 4 deletions
diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php
index 9aeb2ef17..608237ce1 100644
--- a/include/photo/photo_driver.php
+++ b/include/photo/photo_driver.php
@@ -482,7 +482,6 @@ function guess_image_type($filename, $headers = '') {
// logger('Photo: guess_image_type: '.$filename . ($headers?' from curl headers':''), LOGGER_DEBUG);
$type = null;
if ($headers) {
-
$hdrs=array();
$h = explode("\n",$headers);
foreach ($h as $l) {
@@ -490,11 +489,16 @@ function guess_image_type($filename, $headers = '') {
$hdrs[strtolower($k)] = $v;
}
logger('Curl headers: '.var_export($hdrs, true), LOGGER_DEBUG);
- if (array_key_exists('content-type', $hdrs))
+ if (array_key_exists('content-type', $hdrs)) {
$type = $hdrs['content-type'];
+
+ $ph = photo_factory('');
+ $types = $ph->supportedTypes();
+
+ $type = $types[$type];
+ }
}
if (is_null($type)){
-
$ignore_imagick = get_config('system', 'ignore_imagick');
// Guessing from extension? Isn't that... dangerous?
if(class_exists('Imagick') && file_exists($filename) && is_readable($filename) && !$ignore_imagick) {
@@ -638,7 +642,6 @@ function import_xchan_photo($photo,$xchan,$thing = false,$force = false) {
$img_str = $result['body'];
$type = guess_image_type($photo, $result['header']);
$modified = gmdate('Y-m-d H:i:s', (preg_match('/last-modified: (.+) \S+/i', $result['header'], $o) ? strtotime($o[1] . 'Z') : time()));
-
if(is_null($type))
$photo_failure = true;
}