* Licensed under the GNU GPL. For full terms see the file COPYING.
*
* This contains functions needed to handle mime messages.
*
* $Id$
* Licensed under the GNU GPL. For full terms see the file COPYING.
*
* This contains functions needed to handle mime messages.
*
* $Id$
- /* First we unfold the header */
- $hdr = trim(str_replace(array("\r\n\t", "\r\n "),array('', ''), $hdr));
+ /* First we replace \r\n by \n and unfold the header */
+ $hdr = trim(str_replace(array("\r\n", "\n\t", "\n "),array("\n", ' ', ' '), $hdr));
foreach ($hdr as $line) {
$pos = strpos($line, ':');
if ($pos > 0) {
foreach ($hdr as $line) {
$pos = strpos($line, ':');
if ($pos > 0) {
+ 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;
* them in an address stucture object.
* input: $address = string
* $ar = boolean (return array instead of only the
* first element)
* $addr_ar = array with parsed addresses // obsolete
* $group = string // obsolete
* them in an address stucture object.
* input: $address = string
* $ar = boolean (return array instead of only the
* first element)
* $addr_ar = array with parsed addresses // obsolete
* $group = string // obsolete
* addresses without a domainname)
* $lookup = callback function (for lookup address
* strings which are probably nicks
* addresses without a domainname)
* $lookup = callback function (for lookup address
* strings which are probably nicks
* output: array with addressstructure objects or only one
* address_structure object.
* personal name: encoded: =?charset?Q|B?string?=
* output: array with addressstructure objects or only one
* address_structure object.
* personal name: encoded: =?charset?Q|B?string?=
$oAddr = end($aAddress);
if(!$oAddr || ((isset($oAddr)) && !$oAddr->mailbox && !$oAddr->personal)) {
$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();
$aAddress[] = $this->createAddressObject($aStack,$aComment,$sEmail,$sGroup);
$sGroup = '';
$aStack = $aComment = array();
case ',':
$aAddress[] = $this->createAddressObject($aStack,$aComment,$sEmail,$sGroup);
break;
case ',':
$aAddress[] = $this->createAddressObject($aStack,$aComment,$sEmail,$sGroup);
break;
$sGroup = trim(implode(' ',$aStack));
$sGroup = preg_replace('/\s+/',' ',$sGroup);
$aStack = array();
$sGroup = trim(implode(' ',$aStack));
$sGroup = preg_replace('/\s+/',' ',$sGroup);
$aStack = array();
function parseContentType($value) {
$pos = strpos($value, ';');
function parseContentType($value) {
$pos = strpos($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 findAddress($address, $recurs = false) {
$result = false;
if (is_array($address)) {
function findAddress($address, $recurs = false) {
$result = false;
if (is_array($address)) {