From e019f2d0f2dc2fbfa345ab5d7ae85e67bfdd76b8 Mon Sep 17 00:00:00 2001 From: alecpl <alec@alec.pl> Date: Sat, 25 Sep 2010 09:03:53 -0400 Subject: [PATCH] - s/RoundCube/Roundcube/ --- program/include/rcube_imap.php | 41 +++++++++++++++++++++++------------------ 1 files changed, 23 insertions(+), 18 deletions(-) diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php index 4dd46e9..b7ba9ab 100644 --- a/program/include/rcube_imap.php +++ b/program/include/rcube_imap.php @@ -4,8 +4,8 @@ +-----------------------------------------------------------------------+ | program/include/rcube_imap.php | | | - | This file is part of the RoundCube Webmail client | - | Copyright (C) 2005-2010, RoundCube Dev. - Switzerland | + | This file is part of the Roundcube Webmail client | + | Copyright (C) 2005-2010, Roundcube Dev. - Switzerland | | Licensed under the GNU GPL | | | | PURPOSE: | @@ -138,9 +138,10 @@ // write error log else if ($this->conn->error) { $this->error_code = $this->conn->errornum; - raise_error(array('code' => 403, 'type' => 'imap', - 'file' => __FILE__, 'line' => __LINE__, - 'message' => $this->conn->error), true, false); + if ($pass && $user) + raise_error(array('code' => 403, 'type' => 'imap', + 'file' => __FILE__, 'line' => __LINE__, + 'message' => $this->conn->error), true, false); } return false; @@ -155,8 +156,7 @@ */ function close() { - if ($this->conn && $this->conn->connected()) - $this->conn->close(); + $this->conn->close(); $this->write_cache(); } @@ -1704,14 +1704,22 @@ else $this->struct_charset = $this->_structure_charset($structure); + $headers->ctype = strtolower($headers->ctype); + // Here we can recognize malformed BODYSTRUCTURE and // 1. [@TODO] parse the message in other way to create our own message structure // 2. or just show the raw message body. // Example of structure for malformed MIME message: - // ("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 2154 70 NIL NIL NIL) - if ($headers->ctype && $headers->ctype != 'text/plain' - && $structure[0] == 'text' && $structure[1] == 'plain') { - return false; + // ("text" "plain" NIL NIL NIL "7bit" 2154 70 NIL NIL NIL) + if ($headers->ctype && !is_array($structure[0]) && $headers->ctype != 'text/plain' + && strtolower($structure[0].'/'.$structure[1]) == 'text/plain') { + // we can handle single-part messages, by simple fix in structure (#1486898) + if (preg_match('/^(text|application)\/(.*)/', $headers->ctype, $m)) { + $structure[0] = $m[1]; + $structure[1] = $m[2]; + } + else + return false; } $struct = &$this->_structure_part($structure); @@ -2231,11 +2239,8 @@ // make sure mailbox exists if ($this->mailbox_exists($mbox_name, true)) { - if ($is_file) { - $separator = rcmail::get_instance()->config->header_delimiter(); - $saved = $this->conn->appendFromFile($mailbox, $message, - $headers, $separator.$separator); - } + if ($is_file) + $saved = $this->conn->appendFromFile($mailbox, $message, $headers); else $saved = $this->conn->append($mailbox, $message); } @@ -3421,7 +3426,7 @@ $name = trim($val['name']); if (preg_match('/^[\'"]/', $name) && preg_match('/[\'"]$/', $name)) - $name = preg_replace(array('/^[\'"]/', '/[\'"]$/'), '', $name); + $name = trim($name, '\'"'); if ($name && $address && $name != $address) $string = sprintf('%s <%s>', preg_match("/$special_chars/", $name) ? '"'.addcslashes($name, '"').'"' : $name, $address); @@ -3453,7 +3458,7 @@ function decode_header($input, $remove_quotes=false) { $str = rcube_imap::decode_mime_string((string)$input, $this->default_charset); - if ($str{0}=='"' && $remove_quotes) + if ($str[0] == '"' && $remove_quotes) $str = str_replace('"', '', $str); return $str; -- Gitblit v1.9.1