There was a problem when passing arrays to the decode header. From
[squirrelmail.git] / functions / imap_general.php
index 81c0d9429998b89a82b6571053aa59df5960aac7..12a6c257072465bc35119c8d88e0b2a798ca4aac 100755 (executable)
@@ -69,7 +69,9 @@ function sqimap_read_data_list ($imap_stream, $pre, $handle_errors,
         $data = array();
         $total_size = 0;
         while (strpos($read, "\n") === false) {
-            $read .= fgets($imap_stream, 9096);
+            if(!($read .= fgets($imap_stream, 9096))) {
+                break;
+            }
         }
         
         if (ereg("^\\* [0-9]+ FETCH.*\\{([0-9]+)\\}", $read, $regs)) {
@@ -84,7 +86,9 @@ function sqimap_read_data_list ($imap_stream, $pre, $handle_errors,
         }
         while (1) {
             while (strpos($read, "\n") === false) {
-                $read .= fgets($imap_stream, 9096);
+                if(!($read .= fgets($imap_stream, 9096))) {
+                    break;
+                }
             }
             // If we know the size, no need to look at the end parameters
             if ($size > 0) {
@@ -360,9 +364,13 @@ function sqimap_find_email ($string) {
  */
 function sqimap_find_displayable_name ($string) {
     $string = trim($string);
-    
+
     if ( ereg('^(.+)<.*>', $string, $regs) ) {
-        $string = ereg_replace ('"', '', $regs[1] );
+        $orig_string = $string;
+        $string = str_replace ('"', '', $regs[1] );
+        if (trim($string) == '') {
+             $string = sqimap_find_email($orig_string);
+        }
         if( $string == '' || $string == ' ' ){
             $string = '&nbsp';
         }
@@ -379,7 +387,7 @@ function sqimap_find_displayable_name ($string) {
         }
     }
     else {
-        $string = sqimap_find_email($string);
+        $string = str_replace ('"', '', sqimap_find_email($string));
     }
 
     return trim($string);