Fix MIME determination when no extension is present.
authorMichael M Slusarz <slusarz@curecanti.org>
Mon, 15 Dec 2008 19:19:41 +0000 (12:19 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Mon, 15 Dec 2008 22:37:36 +0000 (15:37 -0700)
framework/Mime/lib/Horde/Mime/Magic.php

index 9e9e516..5c2520b 100644 (file)
@@ -101,12 +101,14 @@ class Horde_Mime_Magic
 
         $map = self::_getMimeExtensionMap();
         for ($i = 0; $i <= $map['__MAXPERIOD__']; ++$i) {
-            $pos = strrpos(substr($filename, 0, $pos - 1), '.') + 1;
+            $pos = strrpos(substr($filename, 0, $pos - 1), '.');
             if ($pos === false) {
                 break;
             }
+            ++$pos;
         }
-        $type = self::extToMime(substr($filename, $pos));
+
+        $type = ($pos === false) ? '' : self::extToMime(substr($filename, $pos));
 
         return (empty($type) || (!$unknown && (strpos($type, 'x-extension') !== false)))
             ? 'application/octet-stream'