Changeset 1195 in subversion


Ignore:
Timestamp:
Mar 21, 2008 7:45:46 AM (5 years ago)
Author:
thomasb
Message:

Add configurable default charset for message decoding

Location:
trunk/roundcubemail
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/CHANGELOG

    r1155 r1195  
    11CHANGELOG RoundCube Webmail 
    22--------------------------- 
     3 
     42008/03/21 (thomasb) 
     5---------- 
     6- Add configurable default charset for message decoding 
     7 
    38 
    492008/02/28 (thomasb) 
  • trunk/roundcubemail/config/main.inc.php.dist

    r1129 r1195  
    180180// 0 = ask the user, 1 = send automatically, 2 = ignore (never send or ask) 
    181181$rcmail_config['mdn_requests'] = 0; 
     182 
     183// Use this as charset as fallback for message decoding 
     184$rcmail_config['default_charset'] = 'ISO-8859-1'; 
    182185 
    183186// Make use of the built-in spell checker. It is based on GoogieSpell. 
  • trunk/roundcubemail/program/include/main.inc

    r1194 r1195  
    291291  { 
    292292  global $CONFIG, $IMAP; 
     293   
     294  if (!empty($CONFIG['default_charset'])) 
     295    $IMAP->set_charset($CONFIG['default_charset']); 
    293296 
    294297  // set root dir from config 
  • trunk/roundcubemail/program/include/rcube_imap.inc

    r1050 r1195  
    5252  var $delimiter = NULL; 
    5353  var $caching_enabled = FALSE; 
     54  var $default_charset = 'ISO-8859-1'; 
    5455  var $default_folders = array('INBOX'); 
    5556  var $default_folders_lc = array('inbox'); 
     
    205206 
    206207  /** 
     208   * Set default message charset 
     209   * 
     210   * This will be used for message decoding if a charset specification is not available 
     211   * 
     212   * @param  string   Charset string 
     213   * @access public 
     214   */ 
     215  function set_charset($cs) 
     216    { 
     217    $this->default_charset = $ch; 
     218    } 
     219 
     220 
     221  /** 
    207222   * This list of folders will be listed above all other folders 
    208223   * 
     
    11471162    // normalize filename property 
    11481163    if ($filename_mime = $struct->d_parameters['filename'] ? $struct->d_parameters['filename'] : $struct->ctype_parameters['name']) 
    1149       $struct->filename = $this->decode_mime_string($filename_mime); 
     1164      $struct->filename = rcube_imap::decode_mime_string($filename_mime, $this->default_charset); 
    11501165    else if ($filename_encoded = $struct->d_parameters['filename*'] ? $struct->d_parameters['filename*'] : $struct->ctype_parameters['name*']) 
    11511166    { 
     
    11551170    } 
    11561171    else if (!empty($struct->headers['content-description'])) 
    1157       $struct->filename = $this->decode_mime_string($struct->headers['content-description']); 
     1172      $struct->filename = rcube_imap::decode_mime_string($struct->headers['content-description'], $this->default_charset); 
    11581173       
    11591174    return $struct; 
     
    12421257      if ($o_part->ctype_primary=='text' || $o_part->ctype_primary=='message') 
    12431258        { 
    1244         // assume ISO-8859-1 if no charset specified 
     1259        // assume default if no charset specified 
    12451260        if (empty($o_part->charset)) 
    1246           $o_part->charset = 'ISO-8859-1'; 
     1261          $o_part->charset = $this->default_charset; 
    12471262 
    12481263        $body = rcube_charset_convert($body, $o_part->charset); 
     
    22982313  function decode_header($input, $remove_quotes=FALSE) 
    22992314    { 
    2300     $str = $this->decode_mime_string((string)$input); 
     2315    $str = rcube_imap::decode_mime_string((string)$input, $this->default_charset); 
    23012316    if ($str{0}=='"' && $remove_quotes) 
    23022317      $str = str_replace('"', '', $str); 
     
    24152430 
    24162431    // defaults to what is specified in the class header 
    2417     return rcube_charset_convert($body,  'ISO-8859-1'); 
     2432    return rcube_charset_convert($body,  $this->default_charset); 
    24182433    } 
    24192434 
  • trunk/roundcubemail/program/steps/mail/compose.inc

    r1039 r1195  
    9191  $MESSAGE = array('UID' => $msg_uid); 
    9292  $MESSAGE['headers'] = &$IMAP->get_headers($msg_uid); 
    93   $MESSAGE['structure'] = &$IMAP->get_structure($msg_uid);   
     93  $MESSAGE['structure'] = &$IMAP->get_structure($msg_uid); 
     94   
     95  if (!empty($MESSAGE['headers']->charset)) 
     96    $IMAP->set_charset($MESSAGE['headers']->charset); 
     97     
    9498  $MESSAGE['subject'] = $IMAP->decode_header($MESSAGE['headers']->subject); 
    9599  $MESSAGE['parts'] = $IMAP->get_mime_numbers($MESSAGE['structure']); 
  • trunk/roundcubemail/program/steps/mail/show.inc

    r1046 r1195  
    3030  $MESSAGE = array('UID' => get_input_value('_uid', RCUBE_INPUT_GET)); 
    3131  $MESSAGE['headers'] = $IMAP->get_headers($MESSAGE['UID']); 
     32   
     33  // set message charset as default 
     34  if (!empty($MESSAGE['headers']->charset)) 
     35    $IMAP->set_charset($MESSAGE['headers']->charset); 
    3236   
    3337  // go back to list if message not found (wrong UID) 
  • trunk/roundcubemail/program/steps/mail/viewsource.inc

    r850 r1195  
    66 |                                                                       | 
    77 | This file is part of the RoundCube Webmail client                     | 
    8  | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland                 | 
     8 | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland                 | 
    99 | Licensed under the GNU GPL                                            | 
    1010 |                                                                       | 
     
    2323// similar code as in program/steps/mail/get.inc 
    2424if ($uid = get_input_value('_uid', RCUBE_INPUT_GET)) 
    25   { 
    26   header('Content-Type: text/plain'); 
    27   //@ob_end_clean(); 
     25{ 
     26  $headers = $IMAP->get_headers($uid); 
     27  $charset = $headers->charset ? $headers->charset : $IMAP->default_charset; 
     28  header("Content-Type: text/plain; charset={$charset}"); 
    2829  $IMAP->print_raw_body($uid); 
    29   } 
     30} 
    3031else 
    31   { 
    32   raise_error(array('code' => 500, 
    33                     'type' => 'php', 
    34                     'message' => 'Message UID '.$uid.' not found'), 
    35               TRUE, 
    36               TRUE); 
    37   } 
     32{ 
     33  raise_error(array( 
     34      'code' => 500, 
     35      'type' => 'php', 
     36      'message' => 'Message UID '.$uid.' not found'), 
     37    true, 
     38    true); 
     39} 
    3840 
    3941exit; 
Note: See TracChangeset for help on using the changeset viewer.