From 583850d00cb61771333a19ed57bef753ac140fe0 Mon Sep 17 00:00:00 2001 From: alecpl <alec@alec.pl> Date: Thu, 08 May 2008 05:07:04 -0400 Subject: [PATCH] - Corrected message headers decoding when charset isn't specified and improved support for native languages (#1485050, #1485048) --- CHANGELOG | 2 ++ program/include/rcube_imap.php | 2 +- program/steps/mail/func.inc | 18 ++++++++++++------ program/steps/mail/show.inc | 2 +- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ecdd692..b63e610 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,6 +6,8 @@ - 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 2716934..9acb60b 100644 --- a/program/include/rcube_imap.php +++ b/program/include/rcube_imap.php @@ -2361,7 +2361,7 @@ } // 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 36bd4cb..073950a 100644 --- a/program/steps/mail/func.inc +++ b/program/steps/mail/func.inc @@ -232,16 +232,19 @@ $out .= sprintf("<td class=\"icon\">%s</td>\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('<a href="%s" onclick="return rcube_event.cancel(event)">%s</a>', Q(rcmail_url($action, array($uid_param=>$header->uid, '_mbox'=>$mbox))), $cont); } @@ -321,16 +324,19 @@ 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('<a href="%s" onclick="return rcube_event.cancel(event)">%s</a>', Q(rcmail_url($action, array($uid_param=>$header->uid, '_mbox'=>$mbox))), $cont); } @@ -974,7 +980,7 @@ 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<tr>\n"; $out .= '<td class="header-title">'.Q(rcube_label($hkey)).": </td>\n"; @@ -1466,7 +1472,7 @@ $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 8062f45..daf2e08 100644 --- a/program/steps/mail/show.inc +++ b/program/steps/mail/show.inc @@ -61,7 +61,7 @@ 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'])) -- Gitblit v1.9.1