Changeset aa16b4a in github for program/include/rcube_message.php
- Timestamp:
- Dec 23, 2009 3:01:39 AM (3 years ago)
- Branches:
- master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
- Children:
- 1004407
- Parents:
- be11a9f
- File:
-
- 1 edited
-
program/include/rcube_message.php (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
program/include/rcube_message.php
refe5a55 raa16b4a 225 225 * @param object rcube_message_part Message structure node 226 226 * @param bool True when called recursively 227 * @param bool True when message should be parsed as message/alternative 228 */ 229 private function parse_structure($structure, $recursive = false, $force_alternative = false) 230 { 231 $message_ctype_primary = strtolower($structure->ctype_primary); 232 $message_ctype_secondary = strtolower($structure->ctype_secondary); 227 */ 228 private function parse_structure($structure, $recursive = false) 229 { 230 $message_ctype_primary = $structure->ctype_primary; 231 $message_ctype_secondary = $structure->ctype_secondary; 232 $mimetype = $structure->mimetype; 233 234 // real content-type of message/rfc822 part 235 if ($mimetype == 'message/rfc822') { 236 if ($structure->real_mimetype) { 237 $mimetype = $structure->real_mimetype; 238 list($message_ctype_primary, $message_ctype_secondary) = explode('/', $mimetype); 239 } 240 } 233 241 234 242 // show message headers … … 246 254 } 247 255 // the same for pgp signed messages 248 else if ($m essage_ctype_primary == 'application' && $message_ctype_secondary == 'pgp' && !$recursive) {256 else if ($mimetype == 'application/pgp' && !$recursive) { 249 257 $structure->type = 'content'; 250 258 $this->parts[] = &$structure; 251 259 } 252 260 // message contains alternative parts 253 else if ($m essage_ctype_primary == 'multipart' && ($message_ctype_secondary == 'alternative')&& is_array($structure->parts)) {261 else if ($mimetype == 'multipart/alternative' && is_array($structure->parts)) { 254 262 // get html/plaintext parts 255 263 $plain_part = $html_part = $print_part = $related_part = null; 256 264 257 265 foreach ($structure->parts as $p => $sub_part) { 258 $rel_parts = $attachmnts = null; 259 $sub_ctype_primary = strtolower($sub_part->ctype_primary); 260 $sub_ctype_secondary = strtolower($sub_part->ctype_secondary); 266 $sub_mimetype = $sub_part->mimetype; 261 267 262 // check if sub part is 263 if ($sub_ ctype_primary=='text' && $sub_ctype_secondary=='plain')268 // check if sub part is 269 if ($sub_mimetype == 'text/plain') 264 270 $plain_part = $p; 265 else if ($sub_ ctype_primary=='text' && $sub_ctype_secondary=='html')271 else if ($sub_mimetype == 'text/html') 266 272 $html_part = $p; 267 else if ($sub_ ctype_primary=='text' && $sub_ctype_secondary=='enriched')273 else if ($sub_mimetype == 'text/enriched') 268 274 $enriched_part = $p; 269 else if ( $sub_ctype_primary=='multipart' && in_array($sub_ctype_secondary, array('related', 'mixed', 'alternative')))275 else if (in_array($sub_mimetype, array('multipart/related', 'multipart/mixed', 'multipart/alternative'))) 270 276 $related_part = $p; 271 277 } … … 319 325 } 320 326 // this is an ecrypted message -> create a plaintext body with the according message 321 else if ($m essage_ctype_primary == 'multipart' && $message_ctype_secondary == 'encrypted') {327 else if ($mimetype == 'multipart/encrypted') { 322 328 $p = new stdClass; 323 329 $p->type = 'content'; … … 341 347 for ($i=0; $i < count($structure->parts); $i++) { 342 348 $mail_part = &$structure->parts[$i]; 343 $primary_type = strtolower($mail_part->ctype_primary); 344 $secondary_type = strtolower($mail_part->ctype_secondary); 349 $primary_type = $mail_part->ctype_primary; 350 $secondary_type = $mail_part->ctype_secondary; 351 352 // real content-type of message/rfc822 353 if ($mail_part->real_mimetype) { 354 $part_orig_mimetype = $mail_part->mimetype; 355 $part_mimetype = $mail_part->real_mimetype; 356 list($primary_type, $secondary_type) = explode('/', $part_mimetype); 357 } 358 else 359 $part_mimetype = $mail_part->mimetype; 345 360 346 361 // multipart/alternative 347 362 if ($primary_type=='multipart') { 348 363 $this->parse_structure($mail_part, true); 364 365 // list message/rfc822 as attachment as well (mostly .eml) 366 if ($part_orig_mimetype == 'message/rfc822' && !empty($mail_part->filename)) 367 $this->attachments[] = $mail_part; 349 368 } 350 369 // part text/[plain|html] OR message/delivery-status 351 else if (( $primary_type == 'text' && ($secondary_type == 'plain' || $secondary_type == 'html') && $mail_part->disposition != 'attachment') ||352 ($primary_type == 'message' && ($secondary_type == 'delivery-status' || $secondary_type == 'disposition-notification'))) {370 else if ((($part_mimetype == 'text/plain' || $part_mimetype == 'text/html') && $mail_part->disposition != 'attachment') || 371 $part_mimetype == 'message/delivery-status' || $part_mimetype == 'message/disposition-notification') { 353 372 354 373 // add text part if it matches the prefs 355 if ( (!$this->parse_alternative && !$force_alternative)||374 if (!$this->parse_alternative || 356 375 ($secondary_type == 'html' && $this->opt['prefer_html']) || 357 376 ($secondary_type == 'plain' && !$this->opt['prefer_html'])) { … … 366 385 // part message/* 367 386 else if ($primary_type=='message') { 368 // let's try to find out if message/rfc822 is a multipart/alternative 369 if ($secondary_type == 'rfc822' && is_array($mail_part->parts) && count($mail_part->parts) > 1) { 370 $types = array(); 371 // iterate over parts to find its types and count them by type 372 for ($j=0; $j < count($mail_part->parts); $j++) { 373 $_type = strtolower($mail_part->parts[$j]->ctype_primary).'/'.strtolower($mail_part->parts[$j]->ctype_secondary); 374 $types[$_type] = $types[$_type] ? $types[$_type]+1 : 1; 375 } 376 if ($types['text/plain'] == 1 && $types['text/html'] == 1) 377 $_alternative = true; 378 } 379 $this->parse_structure($mail_part, true, $_alternative); 387 $this->parse_structure($mail_part, true); 380 388 381 389 // list as attachment as well (mostly .eml) … … 388 396 389 397 // part is Microsoft Outlook TNEF (winmail.dat) 390 else if ($p rimary_type == 'application' && $secondary_type == 'ms-tnef') {398 else if ($part_mimetype == 'application/ms-tnef') { 391 399 foreach ((array)$this->imap->tnef_decode($mail_part, $structure->headers['uid']) as $tnef_part) { 392 400 $this->mime_parts[$tnef_part->mime_id] = $tnef_part; … … 404 412 405 413 // part belongs to a related message and is linked 406 if ($m essage_ctype_secondary == 'related'407 && preg_match('!^image/!', $ mail_part->mimetype)414 if ($mimetype == 'multipart/related' 415 && preg_match('!^image/!', $part_mimetype) 408 416 && ($mail_part->headers['content-id'] || $mail_part->headers['content-location'])) { 409 417 if ($mail_part->headers['content-id']) … … 415 423 } 416 424 // is a regular attachment 417 else if (preg_match('!^[a-z]+/[a-z0-9-.+]+$!i', $ mail_part->mimetype)) {425 else if (preg_match('!^[a-z]+/[a-z0-9-.+]+$!i', $part_mimetype)) { 418 426 if (!$mail_part->filename) 419 427 $mail_part->filename = 'Part '.$mail_part->mime_id; … … 424 432 425 433 // if this was a related part try to resolve references 426 if ($m essage_ctype_secondary == 'related' && sizeof($this->inline_parts)) {434 if ($mimetype == 'multipart/related' && sizeof($this->inline_parts)) { 427 435 $a_replaces = array(); 428 436 … … 444 452 } 445 453 446 // message is single part non-text454 // message is a single part non-text 447 455 else if ($structure->filename) { 448 456 $this->attachments[] = $structure;
Note: See TracChangeset
for help on using the changeset viewer.
