From: Florent Bruneau Date: Sun, 31 Aug 2008 15:01:59 +0000 (+0200) Subject: Fix parsing of messages containing UUEncoded data. X-Git-Url: http://git.polytechnique.org/?p=banana.git;a=commitdiff_plain;h=6ec8703c9a26dc36334478488789433b00c471d7 Fix parsing of messages containing UUEncoded data. Signed-off-by: Florent Bruneau --- diff --git a/banana/mbox.inc.php b/banana/mbox.inc.php index cb4faa2..1f158c9 100644 --- a/banana/mbox.inc.php +++ b/banana/mbox.inc.php @@ -302,7 +302,7 @@ class BananaMBox implements BananaProtocoleInterface */ private function getMBoxPosition(array &$options, $id = null) { - if (Banana::$spool->overview) { + if (Banana::$spool && Banana::$spool->overview) { if (!is_null($id) && isset(Banana::$spool->overview[$id])) { $key = $id; } else { diff --git a/banana/mimepart.inc.php b/banana/mimepart.inc.php index 743ced2..577af46 100644 --- a/banana/mimepart.inc.php +++ b/banana/mimepart.inc.php @@ -201,7 +201,14 @@ class BananaMimePart $parts = $this->findUUEncoded(); if (count($parts)) { $this->convertToMultiPart(); - $this->multipart = array_merge(array($textpart), $parts); + $this->multipart = array_merge($this->multipart, $parts); + // Restore "message" headers to the previous level" + $this->headers = array(); + foreach (Banana::$msgshow_headers as $hdr) { + if (isset($this->multipart[0]->headers[$hdr])) { + $this->headers[$hdr] = $this->multipart[0]->headers[$hdr]; + } + } } } } @@ -260,11 +267,12 @@ class BananaMimePart if ($mime != 'application/x-empty') { $this->body = trim(str_replace($match[0], '', $this->body)); $newpart = new BananaMimePart; + self::decodeHeader($match[2]); $newpart->makeDataPart($data, $mime, '8bit', $match[2], 'attachment'); $parts[] = $newpart; } - } - } + } + } return $parts; } @@ -275,7 +283,7 @@ class BananaMimePart return str_replace('_', ' ', $s); } - static public function decodeHeader(&$val, $key) + static public function decodeHeader(&$val, $key = null) { if (preg_match('/[\x80-\xff]/', $val)) { if (!is_utf8($val)) {