mime_fetch_body reworked to fix a bug I found on my system. It also now
authorfidian <fidian@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 5 Dec 2000 19:43:52 +0000 (19:43 +0000)
committerfidian <fidian@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 5 Dec 2000 19:43:52 +0000 (19:43 +0000)
uses imap_read_data() instead of reading data directly.

git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@861 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/mime.php

index 13a453a9ef89983746d790814344a98011d778c9..cab32d51ce4b147c194e4b686ee3934e3f98ad51 100644 (file)
       if (!$ent_id) $ent_id = 1;
 
       fputs ($imap_stream, "a001 FETCH $id BODY[$ent_id]\r\n");
-      $topline = fgets ($imap_stream, 1024);
+      $data = sqimap_read_data ($imap_stream, 'a001', true, $response, $message);
+      $topline = array_shift($data);
+      while (! ereg('\* [0-9]+ FETCH ', $topline) && data)
+          $topline = array_shift($data);
+      while ($data)
+          $wholemessage .= array_shift($data);
+
       if (ereg('\{([^\}]*)\}', $topline, $regs)) {
-         return fread ($imap_stream, $regs[1]);
+         return substr($wholemessage, 0, $regs[1]);
       }
       else if (ereg('"([^"]*)"', $topline, $regs)) {
          return $regs[1];
       }
+      
+      $str = "Body retrival error.  Please report this bug!\n";
+      $str .= "Response:  $response\n";
+      $str .= "Message:  $message\n";
+      $str .= "FETCH line:  $topline";
+      $str .= "---------------\n$wholemessage";
+      foreach ($data as $d)
+      {
+          $str .= htmlspecialchars($d) . "\n";
+      }
+      return $str;
+      
       return "Body retrival error, please report this bug!\n\nTop line is \"$topline\"\n";
    }