diff -upbr ./webfm.module ../webfm-patched/webfm.module
--- ./webfm.module	2011-02-28 17:10:06.000000000 -0500
+++ ../webfm-patched/webfm.module	2011-03-29 10:46:00.310049200 -0400
@@ -2781,39 +2781,61 @@ function webfm_enum_validate($file, &$er
     return TRUE;
   }
 
-  //Check for possible imagefile exploit
-  //Trying to determine the files mimetype with php
-  //Later we compare the determined mimetype to the one drupal determines.
-  //Drupal (file_get_mimetype) determines the mimetype by mapping the file extension.
+  // Begin check for possible imagefile exploits
+  // Does the extension map to an image mime type?
+  $isExtImage = strpos(file_get_mimetype($file->filepath),'image') !== FALSE;
+  // Only test files with image extensions
+  if ( $isExtImage ) {
+    // Try to determine the files mimetype with php extensions
   $mimetype = ""; //mimetype string
   $extension_error = FALSE;
+    // use Fileinfo extension
   if (extension_loaded('fileinfo')) {
-    //use Fileinfo extension
     static $finfo = FALSE;
     if ($finfo || $finfo = @finfo_open(FILEINFO_MIME_TYPE)) {
       $mimetype = $finfo->file($file->filepath);
     }
   }
-  else {
+    // Use mime magic extensions
+    elseif ( function_exists('mime_content_type') ) {
     $mimetype = mime_content_type($file->filepath);
   }
+    // No extension found
+    else {
+      // probably should be a warning to admin about no extensions.
+      $mimetype = '';
+    }
+
+    // Does the php extension "magic" mimetype function map to an image?
+    $isImage = strpos($mimetype,'image') !== FALSE;
   
-  if (strpos($mimetype,'image') !== FALSE AND strpos(file_get_mimetype($file->filepath),'image') !== FALSE) {
-    //both our $mimetype-check and drupal report this to be an image
-    //we double check with getimagesize
+    // Test to see if php extension was found.  This may be empty if PhP
+    // extension was set up wrong (bad or non-existent magic file).
+    if ( ! empty($mimetype)  ) {
+      // Both our $mimetype-check and drupal report this to be an image
+      if ( $isImage AND $isExtImage ) {
+        // we double check with getimagesize
     if (!@getimagesize($file->filepath)) {
       $extension_error = TRUE;
     }
   }
-  elseif (strpos($mimetype,'image') !== FALSE OR strpos(file_get_mimetype($file->filepath),'image') !== FALSE) {
-    //only one of the checks thinks this is an image.
-    //this covers both cases:
+      // only one of the checks thinks this is an image.
+      // this covers both cases:
     // * javascript/text-file with a wrong extension
     // * image file with a wrong, e.g. "txt" extension
+      elseif ( $isImage OR $isExtImage ) {
     $extension_error = TRUE;
    }
-
-
+    }
+    // File extension says image but can't get php extension mimetype.
+    // So we test by trying to get image size (only works for common
+    // types of png, bmp, gif, and jpeg).
+    else {
+      if (!@getimagesize($file->filepath)) {
+        $extension_error = TRUE;
+      }
+    }
+  }
   
   $webfm_access_roles = webfm_get_access_roles();//load all existing roles
   foreach ($user->roles as $rid => $name) {
