fixed bug reported by V.Richert, about not decoded envelope information; thus allow arrays to be passed and processed to bofelamimail::decode_header; use the new ability; provide better control if data should be decoded or not

This commit is contained in:
Klaus Leithoff 2010-09-10 13:20:35 +00:00
parent 9a37b65ee5
commit 0c89fe6661
2 changed files with 18 additions and 9 deletions

View File

@ -432,6 +432,14 @@
function decode_header($_string)
{
if (is_array($_string))
{
foreach($_string as $k=>$v)
{
$_string[$k] = self::decode_header($v);
}
return $_string;
}
if(function_exists(imap_mime_header_decode)) {
$newString = '';
@ -475,14 +483,14 @@
return preg_replace('/([\000-\012\015\016\020-\037\075])/','',$_string);
}
function decode_subject($_string)
function decode_subject($_string,$decode=true)
{
#$string = $_string;
$_string = self::decode_header($_string);
if($_string=='NIL')
{
$_string = 'No Subject';
return 'No Subject';
}
if ($decode) $_string = self::decode_header($_string);
return $_string;
}
@ -1809,14 +1817,14 @@
return $sortResult;
}
function getMessageEnvelope($_uid, $_partID = '')
function getMessageEnvelope($_uid, $_partID = '',$decode=false)
{
if($_partID == '') {
if( PEAR::isError($envelope = $this->icServer->getEnvelope('', $_uid, true)) ) {
return false;
}
return $envelope[0];
return ($decode ? self::decode_header($envelope[0]): $envelope[0]);
} else {
if( PEAR::isError($headers = $this->icServer->getParsedHeaders($_uid, true, $_partID, true)) ) {
return false;
@ -1832,6 +1840,7 @@
$recepientList = array('FROM', 'TO', 'CC', 'BCC', 'SENDER', 'REPLY_TO');
foreach($recepientList as $recepientType) {
if(isset($headers[$recepientType])) {
if ($decode) $headers[$recepientType] = self::decode_header($headers[$recepientType]);
$addresses = imap_rfc822_parse_adrlist($headers[$recepientType], '');
foreach($addresses as $singleAddress) {
$addressData = array(

View File

@ -257,7 +257,7 @@
#_debug_array($rawheaders);exit;
$attachments = $this->bofelamimail->getMessageAttachments($this->uid, $partID);
#_debug_array($attachments); exit;
$envelope = $this->bofelamimail->getMessageEnvelope($this->uid, $partID);
$envelope = $this->bofelamimail->getMessageEnvelope($this->uid, $partID,true);
#_debug_array($envelope); exit;
// if not using iFrames, we need to retrieve the messageBody here
// by now this is a fixed value and controls the use/loading of the template and how the vars are set.
@ -595,7 +595,7 @@
ENT_QUOTES,$this->displayCharset));
$this->t->set_var("subject_data",
@htmlspecialchars($this->bofelamimail->decode_subject(preg_replace($nonDisplayAbleCharacters,'',$envelope['SUBJECT'])),
@htmlspecialchars($this->bofelamimail->decode_subject(preg_replace($nonDisplayAbleCharacters,'',$envelope['SUBJECT']),false),
ENT_QUOTES,$this->displayCharset));
$this->t->parse("header","message_header",True);
@ -1150,7 +1150,7 @@
$this->bofelamimail->reopen($folder);
# print "$this->mailbox, $this->uid, $partID<br>";
$headers = $this->bofelamimail->getMessageHeader($this->uid, $partID);
$envelope = $this->bofelamimail->getMessageEnvelope($this->uid, $partID);
$envelope = $this->bofelamimail->getMessageEnvelope($this->uid, $partID,true);
# _debug_array($headers);exit;
$rawheaders = $this->bofelamimail->getMessageRawHeader($this->uid, $partID);
$bodyParts = $this->bofelamimail->getMessageBody($this->uid,'',$partID);
@ -1236,7 +1236,7 @@
@htmlspecialchars($GLOBALS['egw']->common->show_date(strtotime($headers['DATE'])), ENT_QUOTES,$this->displayCharset));
// link to go back to the message view. the link differs if the print was called from a normal viewing window, or from compose
$subject = @htmlspecialchars($this->bofelamimail->decode_subject(preg_replace($nonDisplayAbleCharacters, '', $envelope['SUBJECT'])), ENT_QUOTES, $this->displayCharset);
$subject = @htmlspecialchars($this->bofelamimail->decode_subject(preg_replace($nonDisplayAbleCharacters, '', $envelope['SUBJECT']),false), ENT_QUOTES, $this->displayCharset);
$this->t->set_var("subject_data", $subject);
$this->t->set_var("full_subject_data", $subject);
$linkData = array (