From 5f571eb1dba01a5f257c52978f30cd53d773d15c Mon Sep 17 00:00:00 2001 From: alecpl Date: Sat, 11 Jul 2009 20:29:34 +0000 Subject: - few fixes for last commits --- program/include/rcube_imap.php | 8 ++++++-- program/lib/imap.inc | 15 +++++++-------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php index 394b0d758..c82383402 100644 --- a/program/include/rcube_imap.php +++ b/program/include/rcube_imap.php @@ -1162,7 +1162,7 @@ class rcube_imap // write structure to cache if ($this->caching_enabled) - $this->add_message_cache($cache_key, $msg_id, $headers, $struct); + $this->add_message_cache($cache_key, $this->_msg_id, $headers, $struct); } return $struct; @@ -1442,6 +1442,10 @@ class rcube_imap { $structure_str = iil_C_FetchStructureString($this->conn, $this->mailbox, $uid, true); $structure = iml_GetRawStructureArray($structure_str); + // error or message not found + if (empty($structure)) + return false; + $part_type = iml_GetPartTypeCode($structure, $part); $o_part = new rcube_message_part; $o_part->ctype_primary = $part_type==0 ? 'text' : ($part_type==2 ? 'message' : 'other'); @@ -1455,7 +1459,7 @@ class rcube_imap $body = iil_C_HandlePartBody($this->conn, $this->mailbox, $uid, true, $part, $o_part->encoding, $print, $fp); - + if ($fp || $print) return true; diff --git a/program/lib/imap.inc b/program/lib/imap.inc index 0ab2b7fc8..d840befa7 100644 --- a/program/lib/imap.inc +++ b/program/lib/imap.inc @@ -2249,7 +2249,7 @@ function iil_C_HandlePartBody(&$conn, $mailbox, $id, $is_uid=false, $part='', $e $len = $to - $from; $result = substr($line, $from, $len); } - + if ($mode == 1) $result = base64_decode($result); else if ($mode == 2) @@ -2265,7 +2265,7 @@ function iil_C_HandlePartBody(&$conn, $mailbox, $id, $is_uid=false, $part='', $e $sizeStr = substr($line, $from, $len); $bytes = (int)$sizeStr; $prev = ''; - + while ($bytes > 0) { $line = iil_ReadLine($fp, 1024); $len = strlen($line); @@ -2329,7 +2329,7 @@ function iil_C_HandlePartBody(&$conn, $mailbox, $id, $is_uid=false, $part='', $e do { $line = iil_ReadLine($fp, 1024); } while (!iil_StartsWith($line, $key, true)); - + if ($result) { $result = rtrim($result, "\t\r\n\0\x0B"); if ($file) { @@ -2338,9 +2338,9 @@ function iil_C_HandlePartBody(&$conn, $mailbox, $id, $is_uid=false, $part='', $e echo $result; } else return $result; // substr($result, 0, strlen($result)-1); + + return true; } - - return true; } return false; @@ -2480,12 +2480,11 @@ function iil_C_FetchStructureString(&$conn, $folder, $id, $is_uid=false) { do { $line = iil_ReadLine($fp, 5000); $line = iil_MultLine($fp, $line); - list(, $index, $cmd, $rest) = explode(' ', $line); - if ($cmd != 'FETCH' || $index == $id || preg_match("/^$key/", $line)) + if (!preg_match("/^$key/", $line)) $result .= $line; } while (!preg_match("/^$key/", $line)); - $result = trim(substr($result, strpos($result, 'BODYSTRUCTURE')+13, -(strlen($result)-strrpos($result, $key)+1))); + $result = trim(substr($result, strpos($result, 'BODYSTRUCTURE')+13, -1)); } } return $result; -- cgit v1.2.3