Skip to content

Commit

Permalink
Fix inline viewing of image attachments
Browse files Browse the repository at this point in the history
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] #1125
  • Loading branch information
dregad committed Aug 2, 2017
1 parent 5884ba4 commit 54929f3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion file_download.php
Expand Up @@ -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;
Expand Down

0 comments on commit 54929f3

Please sign in to comment.