Changeset 3843 in subversion


Ignore:
Timestamp:
Jul 30, 2010 8:46:00 AM (3 years ago)
Author:
alec
Message:
  • Performance fix: Determine real mimetype of message/rfc822 part from bodystructure instead of fetched headers
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/program/include/rcube_imap.php

    r3842 r3843  
    17391739     * @access private 
    17401740     */ 
    1741     function &_structure_part($part, $count=0, $parent='', $mime_headers=null, $raw_headers=null) 
     1741    function &_structure_part($part, $count=0, $parent='', $mime_headers=null) 
    17421742    { 
    17431743        $struct = new rcube_message_part; 
     
    17791779                    $tmp_part_id = $struct->mime_id ? $struct->mime_id.'.'.($i+1) : $i+1; 
    17801780                    if (strtolower($part[$i][0]) == 'message' && strtolower($part[$i][1]) == 'rfc822') { 
    1781                         $raw_part_headers[] = $tmp_part_id; 
    17821781                        $mime_part_headers[] = $tmp_part_id; 
    17831782                    } 
     
    17951794                    $this->_msg_id, $mime_part_headers); 
    17961795            } 
    1797             // we'll need a real content-type of message/rfc822 part 
    1798             if ($raw_part_headers) { 
    1799                 $raw_part_headers = $this->conn->fetchMIMEHeaders($this->mailbox, 
    1800                     $this->_msg_id, $raw_part_headers, false); 
    1801             } 
    18021796 
    18031797            $struct->parts = array(); 
     
    18071801                $tmp_part_id = $struct->mime_id ? $struct->mime_id.'.'.($i+1) : $i+1; 
    18081802                $struct->parts[] = $this->_structure_part($part[$i], ++$count, $struct->mime_id, 
    1809                     $mime_part_headers[$tmp_part_id], $raw_part_headers[$tmp_part_id]); 
     1803                    $mime_part_headers[$tmp_part_id]); 
    18101804            } 
    18111805 
     
    18991893            $struct->headers = $this->_parse_headers($mime_headers) + $struct->headers; 
    19001894 
    1901             // get real headers for message of type 'message/rfc822' 
     1895            // get real content-type of message/rfc822 
    19021896            if ($struct->mimetype == 'message/rfc822') { 
    1903                 if (empty($raw_headers)) { 
    1904                     $raw_headers = $this->conn->fetchMIMEHeaders( 
    1905                         $this->mailbox, $this->_msg_id, (array)$struct->mime_id, false); 
     1897                // single-part 
     1898                if (!is_array($part[8][0])) 
     1899                    $struct->real_mimetype = strtolower($part[8][0] . '/' . $part[8][1]); 
     1900                // multi-part 
     1901                else { 
     1902                    for ($n=0; $n<count($part[8]); $n++) 
     1903                        if (!is_array($part[8][$n])) 
     1904                            break; 
     1905                    $struct->real_mimetype = 'multipart/' . strtolower($part[8][$n]); 
    19061906                } 
    1907                 $struct->real_headers = $this->_parse_headers($raw_headers); 
    1908  
    1909                 // get real content-type of message/rfc822 
    1910                 if (preg_match('/^([a-z0-9_\/-]+)/i', $struct->real_headers['content-type'], $matches)) { 
    1911                     $struct->real_mimetype = strtolower($matches[1]); 
    1912                 } 
    1913             } 
    1914         } 
    1915  
    1916         if ($struct->ctype_primary == 'message') { 
    1917             if (is_array($part[8]) && $di != 8 && empty($struct->parts)) 
    1918                 $struct->parts[] = $this->_structure_part($part[8], ++$count, $struct->mime_id); 
     1907            } 
     1908 
     1909            if ($struct->ctype_primary == 'message' && empty($struct->parts)) { 
     1910                if (is_array($part[8]) && $di != 8) 
     1911                    $struct->parts[] = $this->_structure_part($part[8], ++$count, $struct->mime_id); 
     1912            } 
    19191913        } 
    19201914 
Note: See TracChangeset for help on using the changeset viewer.