diff --git a/core/util.inc.php b/core/util.inc.php index 60a95b6f..2095d4a6 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -935,6 +935,23 @@ if (!function_exists('http_parse_headers')) { #http://www.php.net/manual/en/func } } +function findHeader ($headers, $name){ + //HTTP Headers can sometimes be lowercase which will cause issues. + //In cases like these, we need to make sure to check for them if the camelcase version does not exist. + $header = FALSE; + + if(array_key_exists($name, $headers)){ + $header = $headers[$name]; + }else{ + $headers = array_change_key_case($headers); + if(array_key_exists(strtolower($name), $headers)){ + $header = $headers[strtolower($name)]; + } + } + + return $header; +} + $_included = array(); /** * Get the active contents of a .php file diff --git a/ext/upload/main.php b/ext/upload/main.php index 028c2857..297656e9 100644 --- a/ext/upload/main.php +++ b/ext/upload/main.php @@ -344,7 +344,9 @@ class Upload extends Extension { $tmp_filename = tempnam(ini_get('upload_tmp_dir'), "shimmie_transload"); $headers = transload($url, $tmp_filename); - $h_filename = (isset($headers['Content-Disposition']) ? preg_replace('/^.*filename="([^ ]+)"/i', '$1', $headers['Content-Disposition']) : null); + + $s_filename = findHeader($headers, 'Content-Disposition'); + $h_filename = ($s_filename ? preg_replace('/^.*filename="([^ ]+)"/i', '$1', $s_filename) : null); $filename = $h_filename ?: basename($url); if(!$headers) { @@ -362,7 +364,7 @@ class Upload extends Extension { $pathinfo = pathinfo($url); $metadata = array(); $metadata['filename'] = $filename; - $metadata['extension'] = getExtension($headers['Content-Type']) ?: $pathinfo['extension']; + $metadata['extension'] = getExtension(findHeader($headers, 'Content-Type')) ?: $pathinfo['extension']; $metadata['tags'] = $tags; $metadata['source'] = (($url == $source) && !$config->get_bool('upload_tlsource') ? "" : $source);