Fix for some problems handling attachments, regarding the logik of the mail-structure object.

This fix adds to the fix of Connie, and focuses on the MULTIPART/ALTERNATIVE part of the mail-structure object
This commit is contained in:
Klaus Leithoff 2007-09-04 08:14:47 +00:00
parent fe80186ba2
commit 25c0ba0ac8

View File

@ -593,7 +593,10 @@
if($structure->subParts[$tempID]->type == 'MESSAGE' && $structure->subParts[$tempID]->subType == 'RFC822' &&
count($structure->subParts[$tempID]->subParts) == 1 &&
$structure->subParts[$tempID]->subParts[$tempID]->type == 'MULTIPART' &&
($structure->subParts[$tempID]->subParts[$tempID]->subType == 'MIXED' || $structure->subParts[$tempID]->subParts[$tempID]->subType == 'REPORT')) {
($structure->subParts[$tempID]->subParts[$tempID]->subType == 'MIXED' ||
$structure->subParts[$tempID]->subParts[$tempID]->subType == 'ALTERNATIVE' ||
$structure->subParts[$tempID]->subParts[$tempID]->subType == 'REPORT'))
{
$structure = $structure->subParts[$tempID]->subParts[$tempID];
} else {
$structure = $structure->subParts[$tempID];
@ -647,6 +650,8 @@
$filename = $this->decode_header($structure->parameters['NAME']);
} elseif(isset($structure->dparameters['FILENAME'])) {
$filename = $this->decode_header($structure->dparameters['FILENAME']);
} elseif(isset($structure->dparameters['FILENAME*'])) {
$filename = $this->decode_header($structure->dparameters['FILENAME*']);
} else {
$filename = lang("unknown");
}
@ -704,6 +709,8 @@
$filename = $this->decode_header($structure->parameters['NAME']);
} elseif(isset($structure->dparameters['FILENAME'])) {
$filename = $this->decode_header($structure->dparameters['FILENAME']);
} elseif(isset($structure->dparameters['FILENAME*'])) {
$filename = $this->decode_header($structure->dparameters['FILENAME*']);
} else {
$filename = lang("unknown");
}
@ -1446,6 +1453,7 @@
$newAttachment['size'] = $structure->bytes;
$newAttachment['mimeType'] = $structure->type .'/'. $structure->subType;
$newAttachment['partID'] = $structure->partID;
$newAttachment['encoding'] = $structure->encoding;
if(isset($structure->cid)) {
$newAttachment['cid'] = $structure->cid;
}
@ -1453,6 +1461,8 @@
$newAttachment['name'] = $this->decode_header($structure->parameters['NAME']);
} elseif(isset($structure->dparameters['FILENAME'])) {
$newAttachment['name'] = $this->decode_header($structure->dparameters['FILENAME']);
} elseif(isset($structure->dparameters['FILENAME*'])) {
$newAttachment['name'] = $this->decode_header($structure->dparameters['FILENAME*']);
} else {
$newAttachment['name'] = lang("unknown");
}
@ -1464,7 +1474,7 @@
// this kind of message can have no attachments
if($structure->type == 'TEXT' ||
($structure->type == 'MULTIPART' && $structure->subType == 'ALTERNATIVE') ||
($structure->type == 'MULTIPART' && $structure->subType == 'ALTERNATIVE' && !is_array($structure->subParts)) ||
!is_array($structure->subParts)) {
return array();
}
@ -1475,7 +1485,12 @@
// skip all non attachment parts
if(($subPart->type == 'TEXT' && ($subPart->subType == 'PLAIN' || $subPart->subType == 'HTML') && $subPart->disposition != 'ATTACHMENT') ||
($subPart->type == 'MULTIPART' && $subPart->subType == 'ALTERNATIVE') ||
($subPart->type == 'MESSAGE' && $subPart->subType == 'delivery-status')) {
($subPart->type == 'MESSAGE' && $subPart->subType == 'delivery-status'))
{
if ($subPart->type == 'MULTIPART' && $subPart->subType == 'ALTERNATIVE')
{
$attachments = $this->getMessageAttachments($_uid, '', $subPart);
}
continue;
}
@ -1488,6 +1503,7 @@
$newAttachment['size'] = $subPart->bytes;
$newAttachment['mimeType'] = $subPart->type .'/'. $subPart->subType;
$newAttachment['partID'] = $subPart->partID;
$newAttachment['encoding'] = $subPart->encoding;
if(isset($subPart->cid)) {
$newAttachment['cid'] = $subPart->cid;
}
@ -1495,6 +1511,8 @@
$newAttachment['name'] = $this->decode_header($subPart->parameters['NAME']);
} elseif(isset($subPart->dparameters['FILENAME'])) {
$newAttachment['name'] = $this->decode_header($subPart->dparameters['FILENAME']);
} elseif(isset($subPart->dparameters['FILENAME*'])) {
$newAttachment['name'] = $this->decode_header($subPart->dparameters['FILENAME*']);
} else {
$newAttachment['name'] = lang("unknown");
}