From 54929f3b4b5df695ce59d8d258fe9aa52482a7dc Mon Sep 17 00:00:00 2001 From: Damien Regad Date: Wed, 2 Aug 2017 14:18:18 +0200 Subject: [PATCH] Fix inline viewing of image attachments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The code extracting the MIME type from the content was incorrect, assuming that a semi-colon would always be present but it's not always the case. This resulted in MIME type being empty, which in turn made the browser download the file instead of displaying the image inline when the web server's content disposition header is set to "attachment". Jan Müller's original patch [1] was replaced by more efficient code. Fixes #12313 [1] https://github.com/mantisbt/mantisbt/pull/1125 --- file_download.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/file_download.php b/file_download.php index 7b9ef8e875..c95f6ceb65 100644 --- a/file_download.php +++ b/file_download.php @@ -198,7 +198,9 @@ 'application/pdf' ); $t_mime_force_attachment = array( 'application/x-shockwave-flash', 'text/html' ); -$t_mime_type = substr( $t_content_type, 0, strpos( $t_content_type, ';' ) ); +# extract mime type from content type +$t_mime_type = explode( ';', $t_content_type, 2 ); +$t_mime_type = $t_mime_type[0]; if( in_array( $t_mime_type, $t_mime_force_inline ) ) { $t_show_inline = true;