Getting ready for 1.4.0 RC1
[squirrelmail.git] / class / mime / Message.class.php
index 9cce1046248ff5a051e4515cf8595ac445122895..59fa5eae717b3cde55bb2854b9b72f63e3da9441 100644 (file)
@@ -3,7 +3,7 @@
 /**
  * Message.class.php
  *
- * Copyright (c) 2002 The SquirrelMail Project Team
+ * Copyright (c) 2003 The SquirrelMail Project Team
  * Licensed under the GNU GPL. For full terms see the file COPYING.
  *
  * This contains functions needed to handle mime messages.
@@ -138,7 +138,7 @@ class Message {
      */
     function parseStructure($read, &$i, $sub_msg = '') {
         $msg = Message::parseBodyStructure($read, $i, $sub_msg);
-        $msg->setEntIds($msg,false,0);
+        if($msg) $msg->setEntIds($msg,false,0);
         return $msg;
     }
     
@@ -279,7 +279,8 @@ class Message {
                 case 'n':
                 case 'N':
                     /* probably NIL argument */
-                    if (strtoupper(substr($read, $i, 4)) == 'NIL ') {
+                    $tmpnil = strtoupper(substr($read, $i, 4));
+                    if ($tmpnil == 'NIL ' || $tmpnil == 'NIL)') {
                         $arg_a[] = '';
                         ++$arg_no;
                         $i += 2;
@@ -374,9 +375,8 @@ class Message {
     function parseEnvelope($read, &$i, $hdr) {
         $arg_no = 0;
         $arg_a = array();
-
+        ++$i;
         for ($cnt = strlen($read); ($i < $cnt) && ($read{$i} != ')'); ++$i) {
-            ++$i;
             $char = strtoupper($read{$i});
             switch ($char) {
                 case '"':
@@ -385,6 +385,9 @@ class Message {
                     break;
                 case '{':
                     $arg_a[] = $this->parseLiteral($read, $i);
+                   /* temp bugfix (SM 1.5 will have a working clean version)
+                      too much work to implement that version right now */
+                   --$i;
                     ++$arg_no;
                     break;
                 case 'N':
@@ -458,8 +461,8 @@ class Message {
        $iPos = strpos($read,'}',$i);
        if ($iPos) {
           $lit_cnt = substr($read, $i, $iPos - $i);
-          $i += strlen($lit_cnt) + 3; /* } + \r + \n */
-          $lit_cnt -= 2; /* lit_cnt includes \r\n */
+          $i += strlen($lit_cnt) + 3; /* skip } + \r + \n */
+          /* Now read the literal */
           $s = ($lit_cnt ? substr($read,$i,$lit_cnt): '');
           $i += $lit_cnt;
        } else { /* should never happen */