alecpl
2012-01-13 4391a7809edae1b552f0720a43924212519900a9
- Make mime type detection based on filename extension to be case-insensitive


3 files modified
19 ■■■■■ changed files
CHANGELOG 1 ●●●● patch | view | raw | blame | history
program/include/main.inc 8 ●●●●● patch | view | raw | blame | history
program/include/rcube_shared.inc 10 ●●●● patch | view | raw | blame | history
CHANGELOG
@@ -1,6 +1,7 @@
CHANGELOG Roundcube Webmail
===========================
- Make mime type detection based on filename extension to be case-insensitive
- Fix failure on MySQL database upgrade from 0.7 - text column can't have default value (#1488300)
- Added address book widget on compose screen
- Use proper timezones from PHP's internal timezonedb (#1485592)
program/include/main.inc
@@ -1627,12 +1627,14 @@
  list($primary, $secondary) = explode('/', $mimetype);
  $classes = array($primary ? $primary : 'unknown');
  if ($secondary)
  if ($secondary) {
    $classes[] = $secondary;
  if (preg_match('/\.([a-z0-9]+)$/', $filename, $m))
  }
  if (preg_match('/\.([a-z0-9]+)$/i', $filename, $m)) {
    $classes[] = $m[1];
  }
  return join(" ", $classes);
  return strtolower(join(" ", $classes));
}
/**
program/include/rcube_shared.inc
@@ -362,12 +362,14 @@
    $mime_type = null;
    $mime_magic = rcmail::get_instance()->config->get('mime_magic');
    $mime_ext = @include(RCMAIL_CONFIG_DIR . '/mimetypes.php');
    $suffix = $name ? substr($name, strrpos($name, '.')+1) : '*';
    // use file name suffix with hard-coded mime-type map
    if (is_array($mime_ext)) {
        $mime_type = $mime_ext[$suffix];
    if (is_array($mime_ext) && $name) {
        if ($suffix = substr($name, strrpos($name, '.')+1)) {
            $mime_type = $mime_ext[strtolower($suffix)];
        }
    }
    // try fileinfo extension if available
    if (!$mime_type && function_exists('finfo_open')) {
        if ($finfo = finfo_open(FILEINFO_MIME, $mime_magic)) {
@@ -378,10 +380,12 @@
            finfo_close($finfo);
        }
    }
    // try PHP's mime_content_type
    if (!$mime_type && !$is_stream && function_exists('mime_content_type')) {
      $mime_type = @mime_content_type($path);
    }
    // fall back to user-submitted string
    if (!$mime_type) {
        $mime_type = $failover;