diff --git a/CHANGELOG b/CHANGELOG index ecdd692f7..b63e610ae 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,6 +6,8 @@ CHANGELOG RoundCube Webmail - Don't attempt to delete cache entries if enable_caching is FALSE (#1485051) - Optimized messages sorting on servers without sort capability (#1485049) - Option 'use_SQL_address_book' replaced by 'address_book_type' +- Corrected message headers decoding when charset isn't specified and improved + support for native languages (#1485050, #1485048) 2008/05/07 (davidke/richs) ---------- diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php index 27169343d..9acb60b49 100644 --- a/program/include/rcube_imap.php +++ b/program/include/rcube_imap.php @@ -2361,7 +2361,7 @@ class rcube_imap } // no encoding information, use fallback - return rcube_charset_convert($input, !empty($fallback) ? $fallback : 'ISO-8859-1'); + return rcube_charset_convert($input, !empty($fallback) ? $fallback : $this->default_charset); } diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc index 36bd4cb89..073950a23 100644 --- a/program/steps/mail/func.inc +++ b/program/steps/mail/func.inc @@ -232,16 +232,19 @@ function rcmail_message_list($attrib) $out .= sprintf("%s\n", $message_icon ? sprintf($image_tag, $skin_path, $message_icon, '') : ''); + if (!empty($header->charset)) + $IMAP->set_charset($header->charset); + // format each col foreach ($a_show_cols as $col) { if ($col=='from' || $col=='to') - $cont = Q(rcmail_address_string(rcube_imap::decode_mime_string($header->$col, $header->charset), 3, $attrib['addicon']), 'show'); + $cont = Q(rcmail_address_string($header->$col, 3, $attrib['addicon']), 'show'); else if ($col=='subject') { $action = $mbox==$CONFIG['drafts_mbox'] ? 'compose' : 'show'; $uid_param = $mbox==$CONFIG['drafts_mbox'] ? '_draf_uid' : '_uid'; - $cont = Q(rcube_imap::decode_mime_string($header->$col, $header->charset)); + $cont = Q($IMAP->decode_header($header->$col)); if (empty($cont)) $cont = Q(rcube_label('nosubject')); $cont = sprintf('%s', Q(rcmail_url($action, array($uid_param=>$header->uid, '_mbox'=>$mbox))), $cont); } @@ -321,16 +324,19 @@ function rcmail_js_message_list($a_headers, $insert_top=FALSE) if (empty($header)) continue; + if (!empty($header->charset)) + $IMAP->set_charset($header->charset); + // format each col; similar as in rcmail_message_list() foreach ($a_show_cols as $col) { if ($col=='from' || $col=='to') - $cont = Q(rcmail_address_string(rcube_imap::decode_mime_string($header->$col, $header->charset), 3), 'show'); + $cont = Q(rcmail_address_string($header->$col, 3), 'show'); else if ($col=='subject') { $action = $mbox==$CONFIG['drafts_mbox'] ? 'compose' : 'show'; $uid_param = $mbox==$CONFIG['drafts_mbox'] ? '_draf_uid' : '_uid'; - $cont = Q(rcube_imap::decode_mime_string($header->$col, $header->charset)); + $cont = Q($IMAP->decode_header($header->$col)); if (!$cont) $cont = Q(rcube_label('nosubject')); $cont = sprintf('%s', Q(rcmail_url($action, array($uid_param=>$header->uid, '_mbox'=>$mbox))), $cont); } @@ -974,7 +980,7 @@ function rcmail_message_headers($attrib, $headers=NULL) else if (in_array($hkey, array('from', 'to', 'cc', 'bcc', 'reply-to'))) $header_value = Q(rcmail_address_string($headers[$hkey], NULL, $attrib['addicon']), 'show'); else - $header_value = Q(rcube_imap::decode_mime_string($headers[$hkey], $headers['charset'])); + $header_value = Q($IMAP->decode_header($headers[$hkey])); $out .= "\n\n"; $out .= ''.Q(rcube_label($hkey)).": \n"; @@ -1466,7 +1472,7 @@ function rcmail_send_mdn($uid) $message = array('UID' => $uid); $message['headers'] = $IMAP->get_headers($message['UID']); - $message['subject'] = rcube_imap::decode_mime_string($message['headers']->subject, $message['headers']->charset); + $message['subject'] = $IMAP->decode_header($message['headers']->subject); if ($message['headers']->mdn_to && !$message['headers']->mdn_sent) { diff --git a/program/steps/mail/show.inc b/program/steps/mail/show.inc index 8062f4598..daf2e0859 100644 --- a/program/steps/mail/show.inc +++ b/program/steps/mail/show.inc @@ -61,7 +61,7 @@ if ($_GET['_uid']) else if (empty($CONFIG['devel_mode'])) send_modified_header($_SESSION['login_time'], $etag, !$MESSAGE['headers']->seen); - $MESSAGE['subject'] = rcube_imap::decode_mime_string($MESSAGE['headers']->subject, $MESSAGE['headers']->charset); + $MESSAGE['subject'] = $IMAP->decode_header($MESSAGE['headers']->subject); $OUTPUT->set_pagetitle($MESSAGE['subject']); if ($MESSAGE['structure'] = $IMAP->get_structure($MESSAGE['UID']))