Changeset 506 in subversion


Ignore:
Timestamp:
Mar 13, 2007 8:39:51 PM (6 years ago)
Author:
thomasb
Message:

Fixed message headers encoding; improved recipient splitting; applied patch for attachment download (#1484198)

Location:
trunk/roundcubemail
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/CHANGELOG

    r502 r506  
    22--------------------------- 
    33 
     42007/03/13 (thomasb) 
     5---------- 
     6- Applied patch for attachment download by crichardson (closes #1484198) 
     7- Fixed bug in Postgres DB handling (closes #1484068) 
     8- Fixed bug of invalid calls to fetchRow() in rcube_db.inc (closes #1484280) 
     9- Fixed array_merge bug (closes #1484281) 
     10- Fixed flag for deletion in list view (closes #1484264) 
     11- Finally support semicolons as recipient separator (closes ##1484251) 
     12- Fixed message headers (subject) encoding 
     13 
     14 
    4152007/03/04 (tomekp) 
     16---------- 
    517- check if safe mode is on or not (closes #1484269) 
     18 
    619 
    7202007/03/02 (thomasb) 
  • trunk/roundcubemail/program/include/rcube_imap.inc

    r504 r506  
    24552455    { 
    24562456    // remove any newlines and carriage returns before 
    2457     $a = $this->_explode_quoted_string(',', preg_replace( "/[\r\n]/", " ", $str)); 
     2457    $a = $this->_explode_quoted_string('[,;]', preg_replace( "/[\r\n]/", " ", $str)); 
    24582458    $result = array(); 
    24592459     
     
    24822482  function _explode_quoted_string($delimiter, $string) 
    24832483    { 
    2484     $quotes = explode("\"", $string); 
    2485     foreach ($quotes as $key => $val) 
    2486       if (($key % 2) == 1) 
    2487         $quotes[$key] = str_replace($delimiter, "_!@!_", $quotes[$key]); 
    2488          
    2489     $string = implode("\"", $quotes); 
    2490  
    2491     $result = explode($delimiter, $string); 
    2492     foreach ($result as $key => $val)  
    2493       $result[$key] = str_replace("_!@!_", $delimiter, $result[$key]); 
    2494      
     2484    $result = array(); 
     2485    $strlen = strlen($string); 
     2486    for ($q=$p=$i=0; $i < $strlen; $i++) 
     2487    { 
     2488      if ($string{$i} == "\"" && $string{$i-1} != "\\") 
     2489        $q = $q ? false : true; 
     2490      else if (!$q && preg_match("/$delimiter/", $string{$i})) 
     2491      { 
     2492        $result[] = substr($string, $p, $i - $p); 
     2493        $p = $i + 1; 
     2494      } 
     2495    } 
     2496     
     2497    $result[] = substr($string, $p); 
    24952498    return $result; 
    24962499    } 
  • trunk/roundcubemail/program/lib/Mail/mime.php

    r399 r506  
    837837                        // quoted-printable encoding has been selected 
    838838                        $mode = 'Q'; 
    839                         $encoded = preg_replace('/([\x20-\x25\x2C\x80-\xFF])/e', "'='.sprintf('%02X', ord('\\1'))", $value); 
     839                        $encoded = preg_replace('/([\x2C\x3F\x80-\xFF])/e', "'='.sprintf('%02X', ord('\\1'))", $value); 
    840840                        // replace spaces with _ 
    841                         $encoded = str_replace('=20', '_', $encoded); 
     841                        $encoded = str_replace(' ', '_', $encoded); 
    842842                    } 
    843843 
  • trunk/roundcubemail/program/steps/mail/get.inc

    r451 r506  
    6464    $filename = $part->d_parameters['filename'] ? $part->d_parameters['filename'] : $part->ctype_parameters['name']; 
    6565 
    66     // send correct headers for content type and length 
     66    header("Expires: 0"); 
     67    header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
     68    header("Cache-Control: private", false); 
     69    header("Content-Transfer-Encoding: binary"); 
     70    header(sprintf('Content-Disposition: attachment; filename="%s";', 
     71                   $filename ? rcube_imap::decode_mime_string($filename) : "roundcube.$ctype_secondary")); 
     72 
     73    // send download headers 
    6774    if ($_GET['_download']) 
    6875      { 
    69       // send download headers 
     76      header("Cache-Control: private", false); 
    7077      header("Content-Type: application/octet-stream"); 
    71       header(sprintf('Content-Disposition: attachment; filename="%s"', 
    72                      $filename ? rcube_imap::decode_mime_string($filename) : "roundcube.$ctype_secondary")); 
    7378      } 
    7479    else 
    75       { 
    7680      header("Content-Type: $mimetype"); 
    77       header(sprintf('Content-Disposition: inline; filename="%s"', rcube_imap::decode_mime_string($filename))); 
    78       } 
    7981 
    8082    // We need to set the following headers to make downloads work using IE in HTTPS mode. 
  • trunk/roundcubemail/program/steps/mail/sendmail.inc

    r454 r506  
    152152$message_charset = isset($_POST['_charset']) ? $_POST['_charset'] : $input_charset; 
    153153 
    154 $mailto_regexp = array('/[,;]\s*[\r\n]+/', '/[\r\n]+/', '/[,;]\s*$/m'); 
    155 $mailto_replace = array(', ', ', ', ''); 
     154$mailto_regexp = array('/[,;]\s*[\r\n]+/', '/[\r\n]+/', '/[,;]\s*$/m', '/;/'); 
     155$mailto_replace = array(', ', ', ', '', ','); 
    156156 
    157157// replace new lines and strip ending ', ' 
     
    171171$headers = array('Date' => date('D, j M Y H:i:s O'), 
    172172                 'From' => rcube_charset_convert($identity_arr['string'], $CHARSET, $message_charset), 
    173                  'To'   => rcube_charset_convert($mailto, $input_charset, $message_charset)); 
     173                 'To'   => $mailto); 
    174174 
    175175// additional recipients 
     
    302302unset($MAIL_MIME->_parts); 
    303303 
     304// encoding subject header with mb_encode provides better results with asian characters 
    304305if ($MBSTRING && function_exists("mb_encode_mimeheader")) 
    305306{ 
    306307  mb_internal_encoding($message_charset); 
    307   $headers['Subject'] = mb_encode_mimeheader($headers['Subject'], $message_charset, 'Q'); 
     308  $mb_subject = mb_encode_mimeheader($headers['Subject'], $message_charset, 'Q'); 
    308309  mb_internal_encoding($CHARSET); 
    309310} 
     
    327328    unset($send_headers['Bcc']); 
    328329   
    329     // generate message headers 
    330     $header_str = $MAIL_MIME->txtHeaders($send_headers); 
     330    if (!empty($mb_subject)) 
     331      $send_headers['Subject'] = $mb_subject; 
    331332   
    332333    // send message 
    333334    $smtp_response = array(); 
    334     $sent = smtp_mail($from, $a_recipients, $header_str, $msg_body, $smtp_response); 
     335    $sent = smtp_mail($from, $a_recipients, $MAIL_MIME->txtHeaders($send_headers), $msg_body, $smtp_response); 
    335336   
    336337    // log error 
     
    353354    unset($headers_php['To'], $headers_php['Subject']); 
    354355     
     356    if (!empty($mb_subject)) 
     357      $headers_enc['Subject'] = $mb_subject; 
     358     
    355359    // reset stored headers and overwrite 
    356360    $MAIL_MIME->_headers = array(); 
     
    358362   
    359363    if (ini_get('safe_mode')) 
    360       $sent = mail($headers_enc['To'], $headers['Subject'], $msg_body, $header_str); 
     364      $sent = mail($headers_enc['To'], $headers_enc['Subject'], $msg_body, $header_str); 
    361365    else 
    362       $sent = mail($headers_enc['To'], $headers['Subject'], $msg_body, $header_str, "-f$from"); 
     366      $sent = mail($headers_enc['To'], $headers_enc['Subject'], $msg_body, $header_str, "-f$from"); 
    363367    } 
    364368   
Note: See TracChangeset for help on using the changeset viewer.