Some string sanity checking; coding format.
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 3 Dec 2008 06:28:00 +0000 (23:28 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 3 Dec 2008 06:28:00 +0000 (23:28 -0700)
framework/Imap_Client/lib/Horde/Imap/Client.php
framework/Imap_Client/lib/Horde/Imap/Client/Base.php

index cdd3bf2..85aa354 100644 (file)
@@ -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);
index 60e44c7..7b7e263 100644 (file)
@@ -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'])) {