Author Topic: Mime Types Check NOT OK During Install  (Read 4569 times)

Offline bsmither

  • Newbie
  • *
  • Posts: 1
Mime Types Check NOT OK During Install
« on: July 10, 2014, 11:07:08 PM »
When installing, and you find yourself with a consistent:
Mimetype to file extension mapping: NOT OK
the problem may, of course, be related to the fact that PHP can't get at the file. If that seems unlikely (you are, after all, a competent server admin), the problem could also be the file's contents. The problem may be a problem with the RoundCube code.

Here is what is happening:
In the file /installer/test.php, a call is made to RCI->check_mime_extensions().

RCI->check_mime_extensions() sends a selection of common mime types to rcube_mime::get_mime_extensions(). The selections are:
application/zip zip
application/x-tar tar
application/java-archive jar
image/gif gif
image/svg+xml svg

rcube_mime::get_mime_extensions() accepts either a mime-type or defaults to null. This function begins by building an array of filepaths to look for the file containing the mime-types. It checks $config['mime_type'] and if not empty, loads that into the array of paths to check. This is not just a path to the file, this is the complete path of the file, 'C:/Hiawatha/conf/mimetypes.conf', for example. It also adds to the array a list of common paths of this file for the operating system being used.

So, if rcube_mime::get_mime_extensions('image/gif') does not return 'gif', then there is a problem. But the message "Please set a valid path to your webserver's mime.types file to the mime_types config option." is ridiculously misleading. There is a problem with the contents of the file.

In my case, there are two problems: (1)the wrong mime-type for 'jar' as listed in the mimetypes.conf file, and (2)RCI->check_mime_extensions() not making the proper check on the result from rcube_mime::get_mime_extensions().

(The mime-types file I am using is supplied by the Hiawatha webserver (up to v9.6).)

(1) The file has:
application/x-java-archive jar
while RCI->check_mime_extensions() is checking:
application/java-archive jar

(2) rcube_mime::get_mime_extensions() scans the file and loads up two arrays. They are:
$mime_types['application/x-tar'] = array('tgz', 'tar')
$mime_extensions = array('tgz' => 'application/x-tar', 'tar' => 'application/x-tar')
(This function also loads in a few less-well-known mime-types in case they are missing from the file.)

So, rcube_mime::get_mime_extensions('application/x-tar') will return array('tgz', 'tar') to RCI->check_mime_extensions() as $ext. Here is the problem:
if ($ext[0] != $expected)
if ('tgz' != 'tar')

RCI->check_mime_extensions() is collecting the errors into an array and returning that array to the test.php code, but the test.php code is simply checking for a non-empty array - not showing the contents of the array. So, you really don't know why it's NOT OK.

The fix:
if (!in_array(strtolower($expected),strtolower($ext)))

If the RoundCube Mailer install code is expecting the file extensions to be in a priority order ('tar' then 'tgz'), then the mimetypes.conf file got that wrong. If there is no priority order in a properly formatted mime-types file, then the installer code got it wrong.

Other posts that were searched and did not provide a satisfactory answer:
http://www.roundcubeforum.net/index.php/topic,16841.msg54634.html#msg54634
http://www.roundcubeforum.net/index.php/topic,19265.msg55252.html#msg55252
http://www.roundcubeforum.net/index.php/topic,15450.msg54178.html#msg54178
http://www.roundcubeforum.net/index.php/topic,16899.msg52586.html#msg52586

Offline alec

  • Hero Member
  • *****
  • Posts: 1,152
Re: Mime Types Check NOT OK During Install
« Reply #1 on: July 11, 2014, 03:43:53 AM »
Thank you for the investigation. I create a ticket http://trac.roundcube.net/ticket/1489983.

Offline wmoreno3

  • Newbie
  • *
  • Posts: 1
Re: Mime Types Check NOT OK During Install
« Reply #2 on: November 30, 2014, 11:03:11 PM »
My system:
Code: [Select]
FreeBSD host.mydomain 10.1-RELEASE FreeBSD 10.1-RELEASE #0 r274401: Tue Nov 11 21:02:49 UTC 2014     root@releng1.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC  amd64
Code: [Select]
vi /usr/local/www/roundcube/config/config.inc.phpAdd:
Code: [Select]
$config['mime_types'] = '/usr/local/etc/apache24/mime.types';Then test again, and OK.

Offline pwn

  • Newbie
  • *
  • Posts: 1
Re: Mime Types Check NOT OK During Install
« Reply #3 on: August 28, 2019, 04:49:32 PM »
The issue could also occur because of general assumption that the 'xampp' should be installed/located on disc 'c:/'. In my case, it is on disk 'd:/'.

So, if the issue occurs, the line 790 in file 'rcube_mime.php' will most likely have to be changed to indicate the correct path to 'mime.types' file.
(in version 1.3.9; '/roundcubemail/program/lib/Roundcube/'):

Code: [Select]
788: // try common locations
789: if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
790: $file_paths[] = 'D:/xampp/apache/conf/mime.types.';
791: }


Offline JohnDoh

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2,285
Re: Mime Types Check NOT OK During Install
« Reply #4 on: August 29, 2019, 02:32:51 AM »
You can set the path with the config param `mime_types`. There is no need to edit core files.
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and moreā€¦