From 59b4e7da38332ecd48c597ca90fe71935a359283 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 2 Dec 2008 23:28:00 -0700 Subject: [PATCH] Some string sanity checking; coding format. --- framework/Imap_Client/lib/Horde/Imap/Client.php | 11 ++++++++++- framework/Imap_Client/lib/Horde/Imap/Client/Base.php | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/framework/Imap_Client/lib/Horde/Imap/Client.php b/framework/Imap_Client/lib/Horde/Imap/Client.php index cdd3bf2af..85aa35446 100644 --- a/framework/Imap_Client/lib/Horde/Imap/Client.php +++ b/framework/Imap_Client/lib/Horde/Imap/Client.php @@ -325,6 +325,10 @@ class Horde_Imap_Client // Rule 1b: Remove superfluous whitespace. $str = preg_replace("/\s{2,}/", '', $str); + if (!$str) { + return ''; + } + do { /* (2) Remove all trailing text of the subject that matches the * the subj-trailer ABNF, repeat until no more matches are @@ -365,6 +369,10 @@ class Horde_Imap_Client { $ret = false; + if (!$str) { + return $ret; + } + if ($str[0] == ' ') { $str = substr($str, 1); $ret = true; @@ -460,7 +468,8 @@ class Horde_Imap_Client */ static final protected function _removeBlobWhenNonempty(&$str) { - if (($str[0] == '[') && + if ($str && + ($str[0] == '[') && (($i = self::_removeBlob($str, 0)) !== false) && ($i != strlen($str))) { $str = substr($str, $i); diff --git a/framework/Imap_Client/lib/Horde/Imap/Client/Base.php b/framework/Imap_Client/lib/Horde/Imap/Client/Base.php index 60e44c752..7b7e26331 100644 --- a/framework/Imap_Client/lib/Horde/Imap/Client/Base.php +++ b/framework/Imap_Client/lib/Horde/Imap/Client/Base.php @@ -2732,7 +2732,7 @@ class Horde_Imap_Client_Search_Query * @param boolean $not If true, do a 'NOT' search of the range. */ public function dateSearch($month, $day, $year, $range, $header = true, - $not = false) + $not = false) { $type = $header ? 'header' : 'internal'; if (!isset($this->_search['date'])) { -- 2.11.0