diff options
Diffstat (limited to 'phpBB')
-rw-r--r-- | phpBB/phpbb/mimetype/content_guesser.php | 16 | ||||
-rw-r--r-- | phpBB/phpbb/mimetype/guesser.php | 4 | ||||
-rw-r--r-- | phpBB/phpbb/plupload/plupload.php | 2 |
3 files changed, 15 insertions, 7 deletions
diff --git a/phpBB/phpbb/mimetype/content_guesser.php b/phpBB/phpbb/mimetype/content_guesser.php index 6bdd410af4..6326bf73fa 100644 --- a/phpBB/phpbb/mimetype/content_guesser.php +++ b/phpBB/phpbb/mimetype/content_guesser.php @@ -492,7 +492,7 @@ class content_guesser * * @return string Guess for mimetype of file */ - public function guess($file) + public function guess($file, $file_name = '') { $mimetype = null; if (function_exists('mime_content_type')) @@ -501,14 +501,22 @@ class content_guesser } else { - $mimetype = $this->map_extension_to_type($file); + $file_name = (empty($file_name)) ? $file : $file_name; + $mimetype = $this->map_extension_to_type($file_name); } return $mimetype; } - protected function map_extension_to_type($file) + /** + * Map extension of supplied file_name to mime type + * + * @param string $file_name Path to file or filename + * + * @return string|null Mimetype if known or null if not + */ + protected function map_extension_to_type($file_name) { - $extension = pathinfo($file, PATHINFO_EXTENSION); + $extension = pathinfo($file_name, PATHINFO_EXTENSION); if (isset($this->extension_map[$extension])) { diff --git a/phpBB/phpbb/mimetype/guesser.php b/phpBB/phpbb/mimetype/guesser.php index 5ae094cd63..231b75f604 100644 --- a/phpBB/phpbb/mimetype/guesser.php +++ b/phpBB/phpbb/mimetype/guesser.php @@ -77,7 +77,7 @@ class guesser * * @return string Guess for mimetype of file */ - public function guess($file) + public function guess($file, $file_name = '') { if (!is_file($file)) { @@ -91,7 +91,7 @@ class guesser foreach ($this->guessers as $guesser) { - $mimetype = $guesser->guess($file); + $mimetype = $guesser->guess($file, $file_name); // Try to guess something that is not the fallback application/octet-stream if ($mimetype !== null && $mimetype !== 'application/octet-stream') diff --git a/phpBB/phpbb/plupload/plupload.php b/phpBB/phpbb/plupload/plupload.php index 29a4aff39b..dedc3cbcd4 100644 --- a/phpBB/phpbb/plupload/plupload.php +++ b/phpBB/phpbb/plupload/plupload.php @@ -135,7 +135,7 @@ class plupload 'tmp_name' => $file_path, 'name' => $this->request->variable('real_filename', ''), 'size' => filesize($file_path), - 'type' => $this->mimetype_guesser->guess($file_path), + 'type' => $this->mimetype_guesser->guess($file_path, $file_name), ); } else |