Skip to content

Commit a677d26

Browse files
committed
Properly attach fetched headers into message parts
1 parent 6e216b5 commit a677d26

File tree

1 file changed

+25
-22
lines changed

1 file changed

+25
-22
lines changed

program/lib/Roundcube/rcube_imap.php

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2232,40 +2232,43 @@ protected function structure_part($part, $count = 0, $parent = '', $mime_headers
22322232

22332233
// fetch message headers if message/rfc822 or named part (could contain Content-Location header)
22342234
if (
2235-
$struct->ctype_primary == 'message'
2236-
|| (!empty($struct->ctype_parameters['name']) && !empty($struct->content_id))
2235+
empty($mime_headers)
2236+
&& (
2237+
$struct->ctype_primary == 'message'
2238+
|| (!empty($struct->ctype_parameters['name']) && !empty($struct->content_id))
2239+
)
22372240
) {
2238-
if (empty($mime_headers)) {
2239-
$mime_headers = $this->conn->fetchPartHeader($this->folder, $this->msg_uid, true, $struct->mime_id);
2240-
}
2241+
$mime_headers = $this->conn->fetchPartHeader($this->folder, $this->msg_uid, true, $struct->mime_id);
2242+
}
22412243

2244+
if (!empty($mime_headers)) {
22422245
if (is_string($mime_headers)) {
22432246
$struct->headers = rcube_mime::parse_headers($mime_headers) + $struct->headers;
22442247
} elseif (is_object($mime_headers)) {
22452248
$struct->headers = get_object_vars($mime_headers) + $struct->headers;
22462249
}
2250+
}
22472251

2248-
// get real content-type of message/rfc822
2249-
if ($struct->mimetype == 'message/rfc822') {
2250-
// single-part
2251-
if (!is_array($part[8][0]) && !is_array($part[8][1])) {
2252-
$struct->real_mimetype = strtolower($part[8][0] . '/' . $part[8][1]);
2253-
}
2254-
// multi-part
2255-
else {
2256-
for ($n = 0; $n < count($part[8]); $n++) {
2257-
if (!is_array($part[8][$n])) {
2258-
break;
2259-
}
2252+
// get real content-type of message/rfc822
2253+
if ($struct->mimetype == 'message/rfc822') {
2254+
// single-part
2255+
if (!is_array($part[8][0]) && !is_array($part[8][1])) {
2256+
$struct->real_mimetype = strtolower($part[8][0] . '/' . $part[8][1]);
2257+
}
2258+
// multi-part
2259+
else {
2260+
for ($n = 0; $n < count($part[8]); $n++) {
2261+
if (!is_array($part[8][$n])) {
2262+
break;
22602263
}
2261-
$struct->real_mimetype = 'multipart/' . strtolower($part[8][$n]);
22622264
}
2265+
$struct->real_mimetype = 'multipart/' . strtolower($part[8][$n]);
22632266
}
2267+
}
22642268

2265-
if ($struct->ctype_primary == 'message' && empty($struct->parts)) {
2266-
if (is_array($part[8]) && $di != 8) {
2267-
$struct->parts[] = $this->structure_part($part[8], ++$count, $struct->mime_id);
2268-
}
2269+
if ($struct->ctype_primary == 'message' && empty($struct->parts)) {
2270+
if (is_array($part[8]) && $di != 8) {
2271+
$struct->parts[] = $this->structure_part($part[8], ++$count, $struct->mime_id);
22692272
}
22702273
}
22712274

0 commit comments

Comments
 (0)