From 7d3f47495d5e8977c051edd5e85ed15e3de6b009 Mon Sep 17 00:00:00 2001 From: x2003bruneau Date: Thu, 11 Jan 2007 14:13:39 +0000 Subject: [PATCH] Fix some warnings and some encoding issues git-svn-id: svn+ssh://murphy/home/svn/banana/trunk@153 9869982d-c50d-0410-be91-f2a2ec7c7c7b --- banana/banana.inc.php.in | 7 +++++-- banana/mbox.inc.php | 16 +++++++++------- banana/nntp.inc.php | 6 ++++-- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/banana/banana.inc.php.in b/banana/banana.inc.php.in index 9095a9b..0a28005 100644 --- a/banana/banana.inc.php.in +++ b/banana/banana.inc.php.in @@ -317,8 +317,11 @@ class Banana } elseif ($partid == 'text') { Banana::$page->assign('body', $msg->getFormattedBody()); } elseif ($partid == 'source') { - Banana::$page->assign('body', - '
' . banana_htmlentities(Banana::$protocole->getMessageSource($artid)) . '
'); + $text = Banana::$protocole->getMessageSource($artid); + if (!is_utf8($text)) { + $text = utf8_encode($text); + } + Banana::$page->assign('body', '
' . banana_htmlentities($text) . '
'); } else { Banana::$page->assign('body', $msg->getFormattedBody($partid)); } diff --git a/banana/mbox.inc.php b/banana/mbox.inc.php index a4827a7..4bd3401 100644 --- a/banana/mbox.inc.php +++ b/banana/mbox.inc.php @@ -99,32 +99,34 @@ class BananaMBox implements BananaProtocoleInterface */ public function &getMessage($id) { + $message = null; if (!is_numeric($id)) { if (!Banana::$spool) { - return null; + return $message; } $id = Banana::$spool->ids[$id]; } $message = $this->readMessages(array($id)); if (empty($message)) { - return null; + $message = null; + return $message; } - $msg = new BananaMessage($message[$id]['message']); - return $msg; + return new BananaMessage($message[$id]['message']); } /** Return the sources of the given message */ public function getMessageSource($id) { + $message = null; if (!is_numeric($id)) { if (!Banana::$spool) { - return null; + return $message; } $id = Banana::$spool->ids[$id]; - } + } $message = $this->readMessages(array($id)); - return implode("\n", $message); + return implode("\n", $message[$id]['message']); } /** Compute the number of messages of the box diff --git a/banana/nntp.inc.php b/banana/nntp.inc.php index 3b02c86..5b9cadd 100644 --- a/banana/nntp.inc.php +++ b/banana/nntp.inc.php @@ -115,7 +115,8 @@ class BananaNNTP extends BananaNNTPCore implements BananaProtocoleInterface if ($data !== false) { return new BananaMessage($data); } - return null; + $data = null; + return $data; } /** Return the sources of the message @@ -134,7 +135,8 @@ class BananaNNTP extends BananaNNTPCore implements BananaProtocoleInterface if ($data !== false) { return implode("\n", $data); } - return null; + $data = null; + return $data; } /** Return the indexes of the messages presents in the Box -- 2.1.4