From 2d32cb9fa03e48b447881b5950ee8e194feb32e5 Mon Sep 17 00:00:00 2001 From: fidian Date: Tue, 5 Dec 2000 19:43:52 +0000 Subject: [PATCH] mime_fetch_body reworked to fix a bug I found on my system. It also now 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 | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/functions/mime.php b/functions/mime.php index 13a453a9..cab32d51 100644 --- a/functions/mime.php +++ b/functions/mime.php @@ -362,13 +362,31 @@ 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"; } -- 2.25.1