Changeset 81b573d in github


Ignore:
Timestamp:
Sep 16, 2008 4:49:28 AM (5 years ago)
Author:
alecpl <alec@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
b62b5a0
Parents:
cf507b2
Message:
  • Reduced memory footprint when forwarding attachments (#1485345)
  • Fixed endless loop in iil_C_HandlePartBody()
  • rcube_message::get_part_content() speed up using 3rd argument of rcube_imap::get_message_part()
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • CHANGELOG

    rf645ce1 r81b573d  
    11CHANGELOG RoundCube Webmail 
    22--------------------------- 
     3 
     42008/09/16 (alec) 
     5---------- 
     6- Reduced memory footprint when forwarding attachments (#1485345) 
    37 
    482008/09/15 (thomasb) 
  • program/include/rcube_imap.php

    re5686f4 r81b573d  
    12841284   * @param  object rcube_message_part Part object created by get_structure() 
    12851285   * @param  mixed  True to print part, ressource to write part contents in 
     1286   * @param  resource File pointer to save the message part 
    12861287   * @return string Message/part body if not printed 
    12871288   */ 
    1288   function &get_message_part($uid, $part=1, $o_part=NULL, $print=NULL) 
     1289  function &get_message_part($uid, $part=1, $o_part=NULL, $print=NULL, $fp=NULL) 
    12891290    { 
    12901291    if (!($msg_id = $this->_uid2id($uid))) 
     
    12941295    if (!is_object($o_part)) 
    12951296      { 
     1297      write_log('errors', 'get_message_part: !is_object'); 
    12961298      $structure_str = iil_C_FetchStructureString($this->conn, $this->mailbox, $msg_id);  
    12971299      $structure = iml_GetRawStructureArray($structure_str); 
     
    13191321    else 
    13201322      { 
    1321       $body = iil_C_HandlePartBody($this->conn, $this->mailbox, $msg_id, $part, 1); 
     1323      if ($fp && $o_part->encoding == 'base64') 
     1324        return iil_C_HandlePartBody($this->conn, $this->mailbox, $msg_id, $part, 3, $fp); 
     1325      else 
     1326        $body = iil_C_HandlePartBody($this->conn, $this->mailbox, $msg_id, $part, 1); 
    13221327 
    13231328      // decode part body 
     
    13341339        $body = rcube_charset_convert($body, $o_part->charset); 
    13351340        } 
    1336       } 
    1337  
     1341       
     1342      if ($fp) 
     1343        { 
     1344        fwrite($fp, $body); 
     1345        return true; 
     1346        } 
     1347      } 
     1348     
    13381349    return $body; 
    13391350    } 
  • program/include/rcube_message.php

    r6695db8 r81b573d  
    118118   * 
    119119   * @param string Part MIME-ID 
     120   * @param resource File pointer to save the message part 
    120121   * @return string Part content 
    121122   */ 
    122   public function get_part_content($mime_id) 
     123  public function get_part_content($mime_id, $fp=NULL) 
    123124  { 
    124125    if ($part = $this->mime_parts[$mime_id]) 
    125       return $this->imap->get_message_part($this->uid, $mime_id, $part); 
     126      return $this->imap->get_message_part($this->uid, $mime_id, $part, NULL, $fp); 
    126127    else 
    127128      return null; 
  • program/lib/imap.inc

    r109314c r81b573d  
    6666                  optional resposne in iil_Connect(), added iil_C_GetCapability() 
    6767                - remove 'undisclosed-recipients' string from 'To' header 
     68                - iil_C_HandlePartBody(): added 6th argument and fixed endless loop 
    6869 
    6970********************************************************/ 
     
    23542355} 
    23552356 
    2356 function iil_C_HandlePartBody(&$conn, $mailbox, $id, $part, $mode) { 
     2357function iil_C_HandlePartBody(&$conn, $mailbox, $id, $part, $mode, $file=NULL) { 
    23572358        /* modes: 
    2358         1: return string 
     2359        1: return string (or write to $file pointer) 
    23592360        2: print 
    2360         3: base64 and print 
     2361        3: base64 and print (or write to $file pointer) 
    23612362        */ 
    23622363         
     
    23642365        $result = false; 
    23652366        if (($part == 0) || empty($part)) { 
    2366             $part = 'TEXT'; 
    2367         } 
    2368      
     2367                $part = 'TEXT'; 
     2368        } 
     2369         
    23692370        if (iil_C_Select($conn, $mailbox)) { 
    23702371                $reply_key = '* ' . $id; 
     
    24002401                                echo $result; 
    24012402                        } else if ($mode == 3) { 
    2402                                 echo base64_decode($result); 
    2403                         } 
     2403                                if ($file) 
     2404                                        fwrite($file, base64_decode($result)); 
     2405                                else 
     2406                                        echo base64_decode($result); 
     2407                        }                             
    24042408                } else if ($line[$len-1] == '}') { 
    24052409                        //multi-line request, find sizes of content and receive that many bytes 
     
    24092413                        $sizeStr  = substr($line, $from, $len); 
    24102414                        $bytes    = (int)$sizeStr; 
    2411                         $received = 0; 
    2412  
    2413                         while ($received < $bytes) { 
    2414                                 $remaining = $bytes - $received; 
    2415                                 $line      = iil_ReadLine($fp, 1024); 
     2415 
     2416                        while ($bytes > 0) { 
     2417                                $line      = iil_ReadLine($fp, 1024); 
    24162418                                $len       = strlen($line); 
    24172419                 
    2418                                 if ($len > $remaining) { 
    2419                                         $line = substr($line, 0, $remaining); 
     2420                                if ($len > $bytes) { 
     2421                                        $line = substr($line, 0, $bytes); 
    24202422                                } 
    2421                                 $received += strlen($line); 
     2423                                $bytes -= strlen($line); 
     2424 
    24222425                                if ($mode == 1) { 
    2423                                         $result .= rtrim($line, "\t\r\n\0\x0B") . "\n"; 
     2426                                        if ($file) 
     2427                                                fwrite($file, rtrim($line, "\t\r\n\0\x0B") . "\n"); 
     2428                                        else 
     2429                                                $result .= rtrim($line, "\t\r\n\0\x0B") . "\n"; 
    24242430                                } else if ($mode == 2) { 
    24252431                                        echo rtrim($line, "\t\r\n\0\x0B") . "\n"; 
    24262432                                } else if ($mode == 3) { 
    2427                                         echo base64_decode($line); 
    2428                                 } 
     2433                                        if ($file) 
     2434                                                fwrite($file, base64_decode($line)); 
     2435                                        else 
     2436                                                echo base64_decode($line); 
     2437                                } 
    24292438                        } 
    24302439                } 
    2431                 // read in anything up until 'til last line 
     2440                // read in anything up until last line 
    24322441                do { 
    24332442                        $line = iil_ReadLine($fp, 1024); 
    24342443                } while (!iil_StartsWith($line, $key)); 
    24352444         
     2445                if ($mode == 3 && $file) { 
     2446                        return true; 
     2447                } 
     2448         
    24362449                if ($result) { 
    24372450                        $result = rtrim($result, "\t\r\n\0\x0B"); 
    2438                         return $result; // substr($result, 0, strlen($result)-1); 
     2451                        if ($file) { 
     2452                                fwrite($file, $result); 
     2453                                return true; 
     2454                        }        
     2455                        return $result; // substr($result, 0, strlen($result)-1); 
    24392456                } 
    24402457                 
     
    24452462     
    24462463        if ($mode==1) { 
     2464                if ($file) { 
     2465                        fwrite($file, $result); 
     2466                        return true; 
     2467                } 
    24472468                return $result; 
    24482469        } 
    2449         return $received; 
    2450 } 
    2451  
    2452 function iil_C_FetchPartBody(&$conn, $mailbox, $id, $part) { 
    2453         return iil_C_HandlePartBody($conn, $mailbox, $id, $part, 1); 
     2470         
     2471        return false; 
     2472} 
     2473 
     2474function iil_C_FetchPartBody(&$conn, $mailbox, $id, $part, $file=NULL) { 
     2475        return iil_C_HandlePartBody($conn, $mailbox, $id, $part, 1, $file); 
    24542476} 
    24552477 
  • program/steps/mail/compose.inc

    ra81be1b r81b573d  
    597597      if ($fp = fopen($tmp_path, 'w')) 
    598598      { 
    599         fwrite($fp, $message->get_part_content($pid)); 
     599        $message->get_part_content($pid, $fp); 
    600600        fclose($fp); 
    601601         
Note: See TracChangeset for help on using the changeset viewer.