fix for not available attachment_common_types array when rg=0
[squirrelmail.git] / functions / imap_parse.php
index 362845966f22b3f6aec5fbcbf79a9c29991e3105..3798bb9898622aaee06963652f9585cc88b48ea6 100644 (file)
@@ -126,7 +126,7 @@ function sqimap_parse_RFC822Header ($read, $hdr) {
             break;
           case 'c': /* Cc */
             if (strtolower(substr($line, 0, 3)) == "cc:") {
-               $hdr->cc = sqimap_parse_address(trim(substr($line, 9, strlen($line) - 10)), true);
+               $hdr->cc = sqimap_parse_address(trim(substr($line, 3, strlen($line) - 4)), true);
             }
             $i++;
             break;
@@ -166,7 +166,7 @@ function sqimap_parse_RFC822Header ($read, $hdr) {
           case 'i': /* Disposition-Notification-To */
              if (strtolower(substr($line, 0, 28)) == "disposition-notification-to:") {
                $dnt = trim(substr($read[$i], 28));
-               $hdr->disposition = sqimap_parse_address($dnt, false);
+               $hdr->dnt = sqimap_parse_address($dnt, false);
             }
             $i++;
             break;
@@ -204,7 +204,7 @@ function sqimap_parse_RFC822Header ($read, $hdr) {
         if (strlen(trim($hdr->subject)) == 0) {
            $hdr->subject = _("(no subject)");
         }
-        if (strlen(trim($hdr->from)) == 0) {
+        if (!is_object($hdr->from) && strlen(trim($hdr->from)) == 0) {
            $hdr->from = _("(unknown sender)");
         }
         if (strlen(trim($hdr->date)) == 0) {
@@ -214,11 +214,20 @@ function sqimap_parse_RFC822Header ($read, $hdr) {
         break;
       case 'x':
         /* X-PRIORITY */
-        if (strtolower(substr($line, 0, 11)) == "x-priority:") {
+        if (strtolower(substr($line, 0, 11)) == 'x-priority:') {
           $hdr->priority = trim(substr($line, 11));
-        } 
+        } else if (strtolower(substr($line,0,9)) == 'x-mailer:') {
+          $hdr->xmailer = trim(substr($line, 9));
+       }
         $i++;
        break;
+     case 'u':
+         /* User-Agent */
+         if (strtolower(substr($line,0,10)) == 'user-agent') {
+             $hdr->xmailer = trim(substr($line, 10));
+         }
+         $i++;
+         break;
       default:
         $i++;
         break;
@@ -279,7 +288,7 @@ function sqimap_parse_address($address, $ar, $addr_ar = array(), $group = '') {
            $name = substr($address,0,$addr_start);
        }
        $at = strpos($addr, '@');
-       $addr_structure = new address_structure();
+       $addr_structure = new AddressStructure();
        $addr_structure->personal = $name;
        $addr_structure->group = $group;
 
@@ -318,7 +327,7 @@ function sqimap_parse_address($address, $ar, $addr_ar = array(), $group = '') {
      $name = substr($address,0,$addr_start);
   }
   $at = strpos($addr, '@');
-  $addr_structure = new address_structure();
+  $addr_structure = new AddressStructure();
   $addr_structure->group = $group;
   if ($at) {
      $addr_structure->mailbox = trim(substr($addr,0,$at));
@@ -345,4 +354,4 @@ function sqimap_parse_address($address, $ar, $addr_ar = array(), $group = '') {
   }          
 
 }
-?>
\ No newline at end of file
+?>