From 896e2b4e5193af26f7bfe8ad96f7a90b8d96c35e Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Tue, 28 May 2013 15:26:44 -0400
Subject: [PATCH] Add more rcube_utils tests

---
 program/lib/Roundcube/rcube_utils.php |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/program/lib/Roundcube/rcube_utils.php b/program/lib/Roundcube/rcube_utils.php
index 8467107..29baa82 100644
--- a/program/lib/Roundcube/rcube_utils.php
+++ b/program/lib/Roundcube/rcube_utils.php
@@ -510,17 +510,24 @@
      */
     public static function file2class($mimetype, $filename)
     {
+        $mimetype = strtolower($mimetype);
+        $filename = strtolower($filename);
+
         list($primary, $secondary) = explode('/', $mimetype);
 
         $classes = array($primary ? $primary : 'unknown');
+
         if ($secondary) {
             $classes[] = $secondary;
         }
-        if (preg_match('/\.([a-z0-9]+)$/i', $filename, $m)) {
-            $classes[] = $m[1];
+
+        if (preg_match('/\.([a-z0-9]+)$/', $filename, $m)) {
+            if (!in_array($m[1], $classes)) {
+                $classes[] = $m[1];
+            }
         }
 
-        return strtolower(join(" ", $classes));
+        return join(" ", $classes);
     }
 
 
@@ -726,7 +733,7 @@
             return mktime(0,0,0, intval($matches[2]), intval($matches[3]), intval($matches[1]));
         }
         else if (is_numeric($date)) {
-            return $date;
+            return (int) $date;
         }
 
         // Clean malformed data
@@ -755,7 +762,7 @@
             $date = implode(' ', $d);
         }
 
-        return $ts;
+        return (int) $ts;
     }
 
 

--
Gitblit v1.9.1