Changeset 95fd49e4 in github


Ignore:
Timestamp:
Jul 30, 2010 8:16:56 AM (3 years ago)
Author:
alecpl <alec@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
2537686
Parents:
e6ce006
Message:
  • Fix message structure parsing when it lacks optional fields (#1486881)
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • CHANGELOG

    rdb1f1e3 r95fd49e4  
    22=========================== 
    33 
     4- Fix message structure parsing when it lacks optional fields (#1486881) 
    45- Include all recipients in sendmail log 
    56- Support HTTP_X_FORWARDED_PROTO header for HTTPS detecting (#1486866) 
  • program/include/rcube_imap.php

    re6ce006 r95fd49e4  
    17481748            $struct->ctype_primary = 'multipart'; 
    17491749 
     1750        /* RFC3501: BODYSTRUCTURE fields of multipart part 
     1751            part1 array 
     1752            part2 array 
     1753            part3 array 
     1754            .... 
     1755            1. subtype 
     1756            2. parameters (optional) 
     1757            3. description (optional) 
     1758            4. language (optional) 
     1759            5. location (optional) 
     1760        */ 
     1761 
    17501762            // find first non-array entry 
    17511763            for ($i=1; $i<count($part); $i++) { 
     
    17591771 
    17601772            // build parts list for headers pre-fetching 
    1761             for ($i=0, $count=0; $i<count($part); $i++) { 
    1762                 if (is_array($part[$i]) && count($part[$i]) > 4) { 
    1763                     // fetch message headers if message/rfc822 
    1764                     // or named part (could contain Content-Location header) 
    1765                     if (!is_array($part[$i][0])) { 
    1766                         $tmp_part_id = $struct->mime_id ? $struct->mime_id.'.'.($i+1) : $i+1; 
    1767                         if (strtolower($part[$i][0]) == 'message' && strtolower($part[$i][1]) == 'rfc822') { 
    1768                             $raw_part_headers[] = $tmp_part_id; 
    1769                             $mime_part_headers[] = $tmp_part_id; 
    1770                         } 
    1771                         else if (in_array('name', (array)$part[$i][2]) && (empty($part[$i][3]) || $part[$i][3]=='NIL')) { 
    1772                             $mime_part_headers[] = $tmp_part_id; 
    1773                         } 
     1773            for ($i=0; $i<count($part); $i++) { 
     1774                if (!is_array($part[$i])) 
     1775                    break; 
     1776                // fetch message headers if message/rfc822 
     1777                // or named part (could contain Content-Location header) 
     1778                if (!is_array($part[$i][0])) { 
     1779                    $tmp_part_id = $struct->mime_id ? $struct->mime_id.'.'.($i+1) : $i+1; 
     1780                    if (strtolower($part[$i][0]) == 'message' && strtolower($part[$i][1]) == 'rfc822') { 
     1781                        $raw_part_headers[] = $tmp_part_id; 
     1782                        $mime_part_headers[] = $tmp_part_id; 
     1783                    } 
     1784                    else if (in_array('name', (array)$part[$i][2]) && (empty($part[$i][3]) || $part[$i][3]=='NIL')) { 
     1785                        $mime_part_headers[] = $tmp_part_id; 
    17741786                    } 
    17751787                } 
     
    17881800                    $this->_msg_id, $raw_part_headers, false); 
    17891801            } 
     1802 
    17901803            $struct->parts = array(); 
    17911804            for ($i=0, $count=0; $i<count($part); $i++) { 
    1792                 if (is_array($part[$i]) && count($part[$i]) > 4) { 
    1793                     $tmp_part_id = $struct->mime_id ? $struct->mime_id.'.'.($i+1) : $i+1; 
    1794                     $struct->parts[] = $this->_structure_part($part[$i], ++$count, $struct->mime_id, 
     1805                if (!is_array($part[$i])) 
     1806                    break; 
     1807                $tmp_part_id = $struct->mime_id ? $struct->mime_id.'.'.($i+1) : $i+1; 
     1808                $struct->parts[] = $this->_structure_part($part[$i], ++$count, $struct->mime_id, 
    17951809                    $mime_part_headers[$tmp_part_id], $raw_part_headers[$tmp_part_id]); 
    1796                 } 
    17971810            } 
    17981811 
    17991812            return $struct; 
    18001813        } 
     1814 
     1815        /* RFC3501: BODYSTRUCTURE fields of non-multipart part 
     1816            0. type 
     1817            1. subtype 
     1818            2. parameters 
     1819            3. id 
     1820            4. description 
     1821            5. encoding 
     1822            6. size 
     1823          -- text 
     1824            7. lines 
     1825          -- message/rfc822 
     1826            7. envelope structure 
     1827            8. body structure 
     1828            9. lines 
     1829          -- 
     1830            x. md5 (optional) 
     1831            x. disposition (optional) 
     1832            x. language (optional) 
     1833            x. location (optional) 
     1834        */ 
    18011835 
    18021836        // regular part 
     
    18261860 
    18271861        // read part disposition 
    1828         $di = count($part) - 2; 
    1829         if ((is_array($part[$di]) && count($part[$di]) == 2 && is_array($part[$di][1])) || 
    1830             (is_array($part[--$di]) && count($part[$di]) == 2)) { 
     1862        $di = 8; 
     1863        if ($struct->ctype_primary == 'text') $di += 1; 
     1864        else if ($struct->mimetype == 'message/rfc822') $di += 3; 
     1865 
     1866        if (is_array($part[$di]) && count($part[$di]) == 2) { 
    18311867            $struct->disposition = strtolower($part[$di][0]); 
    18321868 
     
    18361872        } 
    18371873 
    1838         // get child parts 
     1874        // get message/rfc822's child-parts 
    18391875        if (is_array($part[8]) && $di != 8) { 
    18401876            $struct->parts = array(); 
    1841             for ($i=0, $count=0; $i<count($part[8]); $i++) 
    1842                 if (is_array($part[8][$i]) && count($part[8][$i]) > 5) 
    1843                     $struct->parts[] = $this->_structure_part($part[8][$i], ++$count, $struct->mime_id); 
     1877            for ($i=0, $count=0; $i<count($part[8]); $i++) { 
     1878                if (!is_array($part[8][$i])) 
     1879                    break; 
     1880                $struct->parts[] = $this->_structure_part($part[8][$i], ++$count, $struct->mime_id); 
     1881            } 
    18441882        } 
    18451883 
     
    18761914        } 
    18771915 
    1878         if ($struct->ctype_primary=='message') { 
     1916        if ($struct->ctype_primary == 'message') { 
    18791917            if (is_array($part[8]) && $di != 8 && empty($struct->parts)) 
    18801918                $struct->parts[] = $this->_structure_part($part[8], ++$count, $struct->mime_id); 
Note: See TracChangeset for help on using the changeset viewer.