X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=class%2Fmime%2FRfc822Header.class.php;h=7ecb86bbe2617ffb2a681500bf9df1a4f6591aa3;hb=82d304a0501324b276cabab1870755d5352bd21c;hp=bcacda49280071f33b944e738d25e01b2dbd4734;hpb=2ddf00ae09d3d3b7c06fb721e1477bd144febaa7;p=squirrelmail.git diff --git a/class/mime/Rfc822Header.class.php b/class/mime/Rfc822Header.class.php index bcacda49..7ecb86bb 100644 --- a/class/mime/Rfc822Header.class.php +++ b/class/mime/Rfc822Header.class.php @@ -3,17 +3,18 @@ /** * Rfc822Header.class.php * - * Copyright (c) 2003 The SquirrelMail Project Team + * Copyright (c) 2003-2004 The SquirrelMail Project Team * Licensed under the GNU GPL. For full terms see the file COPYING. * * This contains functions needed to handle mime messages. * * $Id$ + * @package squirrelmail */ -/* - * rdc822_header class +/** * input: header_string or array + * @package squirrelmail */ class Rfc822Header { var $date = '', @@ -21,6 +22,7 @@ class Rfc822Header { $from = array(), $sender = '', $reply_to = array(), + $mail_followup_to = array(), $to = array(), $cc = array(), $bcc = array(), @@ -34,6 +36,8 @@ class Rfc822Header { $priority = 3, $dnt = '', $encoding = '', + $content_id = '', + $content_desc = '', $mlist = array(), $more_headers = array(); /* only needed for constructing headers in smtp.php */ @@ -42,7 +46,7 @@ class Rfc822Header { $hdr = implode('', $hdr); } /* First we unfold the header */ - $hdr = trim(str_replace(array("\r\n\t", "\r\n "),array('', ''), $hdr)); + $hdr = trim(str_replace(array("\r\n\t", "\r\n "),array(' ', ' '), $hdr)); /* Now we can make a new header array with */ /* each element representing a headerline */ @@ -125,6 +129,9 @@ class Rfc822Header { case 'reply-to': $this->reply_to = $this->parseAddress($value, true); break; + case 'mail-followup-to': + $this->mail_followup_to = $this->parseAddress($value, true); + break; case 'to': $this->to = $this->parseAddress($value, true); break; @@ -164,6 +171,16 @@ class Rfc822Header { $value = $this->stripComments($value); $this->parseDisposition($value); break; + case 'content-transfer-encoding': + $this->encoding = $value; + break; + case 'content-description': + $this->content_desc = $value; + break; + case 'content-id': + $value = $this->stripComments($value); + $this->content_id = $value; + break; case 'user-agent': case 'x-mailer': $this->xmailer = $value; @@ -176,11 +193,11 @@ class Rfc822Header { $this->mlist('post', $value); break; case 'list-reply': - $value = $this->stripComments($value); + $value = $this->stripComments($value); $this->mlist('reply', $value); break; case 'list-subscribe': - $value = $this->stripComments($value); + $value = $this->stripComments($value); $this->mlist('subscribe', $value); break; case 'list-unsubscribe': @@ -230,7 +247,7 @@ class Rfc822Header { $i = $iEnd; } $sToken = str_replace($aReplace, $aSpecials,$sToken); - $aTokens[] = $sToken; + if ($sToken) $aTokens[] = $sToken; break; case '"': $iEnd = strpos($address,$cChar,$i+1); @@ -293,24 +310,24 @@ class Rfc822Header { // check the next token in case comments appear in the middle of email addresses $prevToken = end($aTokens); if (!in_array($prevToken,$aSpecials,true)) { - if (isset($address{$i+1}) && !in_array($address{$i+1},$aSpecials,true)) { + if ($i+1createAddressObject($aStack,$aComment,$sEmail,$sGroup); $oAddr = end($aAddress); if(!$oAddr || ((isset($oAddr)) && !$oAddr->mailbox && !$oAddr->personal)) { $sEmail = $sGroup . ':;'; - } + } $aAddress[] = $this->createAddressObject($aStack,$aComment,$sEmail,$sGroup); $sGroup = ''; $aStack = $aComment = array(); @@ -423,8 +441,8 @@ class Rfc822Header { case ',': $aAddress[] = $this->createAddressObject($aStack,$aComment,$sEmail,$sGroup); break; - case ':': - $sGroup = trim(implode(' ',$aStack)); break; + case ':': + $sGroup = trim(implode(' ',$aStack)); $sGroup = preg_replace('/\s+/',' ',$sGroup); $aStack = array(); break; @@ -433,7 +451,7 @@ class Rfc822Header { break; case '>': /* skip */ - break; + break; default: $aStack[] = $sToken; break; } } @@ -468,20 +486,24 @@ class Rfc822Header { if ($sHost && $oAddr->mailbox) { $oAddr->host = $sHost; } + } else if (!$grouplookup && !$oAddr->host) { + if ($sHost && $oAddr->mailbox) { + $oAddr->host = $sHost; + } } } if (!$aAddrBookAddress && $oAddr->mailbox) { $aProcessedAddress[] = $oAddr; } else { - $aProcessedAddress = array_merge($aProcessedAddress,$aAddrBookAddress); + $aProcessedAddress = array_merge($aProcessedAddress,$aAddrBookAddress); } } - if ($ar) { + if ($ar) { return $aProcessedAddress; } else { return $aProcessedAddress[0]; } - } + } function parseContentType($value) { $pos = strpos($value, ';'); @@ -502,37 +524,39 @@ class Rfc822Header { } $this->content_type = $content_type; } - + /* RFC2184 */ - function processParameters($aParameters) { + function processParameters($aParameters) { $aResults = array(); - $aCharset = array(); - // handle multiline parameters + $aCharset = array(); + // handle multiline parameters foreach($aParameters as $key => $value) { - if ($iPos = strpos($key,'*')) { - $sKey = substr($key,0,$iPos); - if (!isset($aResults[$sKey])) { - $aResults[$sKey] = $value; - if (substr($key,-1) == '*') { // parameter contains language/charset info - $aCharset[] = $sKey; - } - } else { - $aResults[$sKey] .= $value; - } - } + if ($iPos = strpos($key,'*')) { + $sKey = substr($key,0,$iPos); + if (!isset($aResults[$sKey])) { + $aResults[$sKey] = $value; + if (substr($key,-1) == '*') { // parameter contains language/charset info + $aCharset[] = $sKey; + } + } else { + $aResults[$sKey] .= $value; + } + } else { + $aResults[$key] = $value; + } } - foreach ($aCharset as $key) { - $value = $aResults[$key]; - // extract the charset & language - $charset = substr($value,0,strpos($value,"'")); - $value = substr($value,strlen($charset)+1); - $language = substr($value,0,strpos($value,"'")); - $value = substr($value,strlen($charset)+1); - // FIX ME What's the status of charset decode with language information ???? - $value = charset_decode($charset,$value); - $aResults[$key] = $value; - } - return $aResults; + foreach ($aCharset as $key) { + $value = $aResults[$key]; + // extract the charset & language + $charset = substr($value,0,strpos($value,"'")); + $value = substr($value,strlen($charset)+1); + $language = substr($value,0,strpos($value,"'")); + $value = substr($value,strlen($charset)+1); + // FIX ME What's the status of charset decode with language information ???? + $value = charset_decode($charset,$value); + $aResults[$key] = $value; + } + return $aResults; } function parseProperties($value) { @@ -661,7 +685,7 @@ class Rfc822Header { } return $arr; } - + function findAddress($address, $recurs = false) { $result = false; if (is_array($address)) { @@ -676,7 +700,7 @@ class Rfc822Header { $result = $i; } } - ++$i; + ++$i; } } else { if (!is_array($this->cc)) $this->cc = array(); @@ -716,7 +740,7 @@ class Rfc822Header { return true; } else { return false; - } + } } //exit; return $result;