Skip to content

Commit

Permalink
Update admin checks to make finfo extension mandatory
Browse files Browse the repository at this point in the history
Fixes #23930
  • Loading branch information
atrol committed Feb 4, 2018
1 parent 8bc7ce5 commit 098fa8f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 40 deletions.
41 changes: 16 additions & 25 deletions admin/check/check_attachments_inc.php
Expand Up @@ -92,29 +92,20 @@
}
}

$t_finfo_exists = class_exists( 'finfo' );
check_print_test_warn_row(
'Fileinfo extension is available for determining file MIME types',
$t_finfo_exists,
array( false => 'Web clients may struggle to download files without knowing the MIME type of each attachment.' )
);

if( $t_finfo_exists ) {
$t_fileinfo_magic_db_file = config_get_global( 'fileinfo_magic_db_file' );
if( $t_fileinfo_magic_db_file ) {
check_print_info_row(
'Name of magic.db file set with the fileinfo_magic_db_file configuration value',
config_get_global( 'fileinfo_magic_db_file' ) );
check_print_test_row(
'fileinfo_magic_db_file configuration value points to an existing magic.db file',
file_exists( $t_fileinfo_magic_db_file ) );
$t_finfo = new finfo( FILEINFO_MIME, $t_fileinfo_magic_db_file );
} else {
$t_finfo = new finfo( FILEINFO_MIME );
}
$t_fileinfo_magic_db_file = config_get_global( 'fileinfo_magic_db_file' );
if( $t_fileinfo_magic_db_file ) {
check_print_info_row(
'Name of magic.db file set with the fileinfo_magic_db_file configuration value',
config_get_global( 'fileinfo_magic_db_file' ) );
check_print_test_row(
'Fileinfo extension can find and load a valid magic.db file',
$t_finfo !== false,
array( false => 'Ensure that the fileinfo_magic_db_file configuration value points to a valid magic.db file.' )
);
}
'fileinfo_magic_db_file configuration value points to an existing magic.db file',
file_exists( $t_fileinfo_magic_db_file ) );
$t_finfo = new finfo( FILEINFO_MIME, $t_fileinfo_magic_db_file );
} else {
$t_finfo = new finfo( FILEINFO_MIME );
}
check_print_test_row(
'Fileinfo extension can find and load a valid magic.db file',
$t_finfo !== false,
array( false => 'Ensure that the fileinfo_magic_db_file configuration value points to a valid magic.db file.' )
);
3 changes: 2 additions & 1 deletion admin/check/check_php_inc.php
Expand Up @@ -50,7 +50,8 @@
'pcre',
'Reflection',
'session',
'mbstring'
'mbstring',
'fileinfo'
);

foreach( $t_extensions_required as $t_extension ) {
Expand Down
2 changes: 1 addition & 1 deletion core/file_api.php
Expand Up @@ -993,7 +993,7 @@ function file_ensure_uploaded( array $p_file ) {
}

/**
* Return instance of fileinfo class if enabled in php
* Return instance of fileinfo class
* @return finfo instance of finfo class.
*/
function file_create_finfo() {
Expand Down
27 changes: 14 additions & 13 deletions docbook/Admin_Guide/en-US/Installation.xml
Expand Up @@ -181,6 +181,19 @@
<listitem><para><emphasis>mbstring</emphasis> -
Required for Unicode (UTF-8) support.
</para></listitem>
<listitem>
<para><emphasis>Fileinfo</emphasis> -
Guesses the MIME type of attachments
</para>
<para>Without this extension, file attachment
previews and downloads do not work
as MantisBT won't be able to send
the Content-Type header to a browser
requesting an attachment.
</para>
<para>This extension is included by default from
PHP version 5.3.x and above.
</para></listitem>
</itemizedlist></listitem>
</varlistentry>

Expand All @@ -195,19 +208,7 @@
required for the captcha feature
</para></listitem>

<listitem>
<para><emphasis>Fileinfo</emphasis> -
Guesses the MIME type of attachments
</para>
<para>Without this extension, file attachment
previews and downloads may not work
correctly as MantisBT won't be able to send
the Content-Type header to a browser
requesting an attachment.
</para>
<para>This extension is included by default from
PHP version 5.3.x and above.
</para></listitem>

</itemizedlist></listitem>
</varlistentry>

Expand Down

0 comments on commit 098fa8f

Please sign in to comment.