From a95e0e174c48b7c5242b8969aef99838a52c41ee Mon Sep 17 00:00:00 2001 From: thomascube Date: Fri, 21 Oct 2005 12:12:23 +0000 Subject: Improved support for UTF-8 and other charsets --- program/steps/error.inc | 1 + program/steps/mail/func.inc | 41 ++++++++++++++++++++----------- program/steps/mail/sendmail.inc | 9 ++++++- program/steps/settings/manage_folders.inc | 6 +++-- 4 files changed, 39 insertions(+), 18 deletions(-) (limited to 'program/steps') diff --git a/program/steps/error.inc b/program/steps/error.inc index 9e5757d7b..aa8036afe 100644 --- a/program/steps/error.inc +++ b/program/steps/error.inc @@ -34,6 +34,7 @@ if ($ERROR_CODE==409) »  Safari 1.2+

»  JavaScript enabled
+»  Support for XMLHTTPRequest

Your configuration:
$user_agent

diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc index 98e0cdbbf..059a8cfcb 100644 --- a/program/steps/mail/func.inc +++ b/program/steps/mail/func.inc @@ -21,6 +21,8 @@ require_once('lib/html2text.inc'); require_once('lib/enriched.inc'); +require_once('lib/utf8.inc'); +require_once('lib/utf7.inc'); $EMAIL_ADDRESS_PATTERN = '/([a-z0-9][a-z0-9\-\.\+\_]*@[a-z0-9]([a-z0-9\-][.]?)*[a-z0-9]\\.[a-z]{2,5})/i'; @@ -157,12 +159,15 @@ function rcmail_render_folder_tree_html(&$arrFolders, &$special, &$mbox, $maxlen if (in_array($folder_lc, $special)) $foldername = rcube_label($folder_lc); else - $foldername = $folder['name']; + { + $foldername = UTF7DecodeString($folder['name']); - // shorten the folder name to a given length - if ($maxlength && $maxlength>1) - $foldername = abbrevate_string($foldername, $maxlength); + // shorten the folder name to a given length + if ($maxlength && $maxlength>1) + $foldername = abbrevate_string($foldername, $maxlength); + } + // add unread message count display if ($unread_count = $IMAP->messagecount($folder['id'], 'UNSEEN', ($folder['id']==$mbox))) $foldername .= sprintf(' (%d)', $unread_count); @@ -176,7 +181,7 @@ function rcmail_render_folder_tree_html(&$arrFolders, &$special, &$mbox, $maxlen $folder['id'], $JS_OBJECT_NAME, $folder['id'], - rep_specialchars_output($foldername)); + rep_specialchars_output($foldername, 'html', 'all')); if (!empty($folder['folders'])) $out .= '\n"; @@ -202,16 +207,18 @@ function rcmail_render_folder_tree_select(&$arrFolders, &$special, &$mbox, $maxl if (in_array($folder_lc, $special)) $foldername = rcube_label($folder_lc); else - $foldername = $folder['name']; - - // shorten the folder name to a given length - if ($maxlength && $maxlength>1) - $foldername = abbrevate_string($foldername, $maxlength); + { + $foldername = UTF7DecodeString($folder['name']); + + // shorten the folder name to a given length + if ($maxlength && $maxlength>1) + $foldername = abbrevate_string($foldername, $maxlength); + } $out .= sprintf(''."\n", $folder['id'], str_repeat(' ', $nestLevel*4), - rep_specialchars_output($foldername)); + rep_specialchars_output($foldername, 'html', 'all')); if (!empty($folder['folders'])) $out .= rcmail_render_folder_tree_select($folder['folders'], $special, $mbox, $maxlength, $nestLevel+1); @@ -600,6 +607,7 @@ function rcmail_parse_message($structure, $arg=array(), $recursive=FALSE) 'body' => $structure->body, 'ctype_primary' => $message_ctype_primary, 'ctype_secondary' => $message_ctype_secondary, + 'parameters' => $structure->ctype_parameters, 'encoding' => $structure->headers['content-transfer-encoding']); } @@ -693,6 +701,7 @@ function rcmail_parse_message($structure, $arg=array(), $recursive=FALSE) 'body' => $mail_part->body, 'ctype_primary' => $primary_type, 'ctype_secondary' => $secondary_type, + 'parameters' => $mail_part->ctype_parameters, 'encoding' => $mail_part->headers['content-transfer-encoding']); } @@ -867,7 +876,9 @@ function rcmail_message_body($attrib) $out .= rcmail_message_headers(sizeof($header_attrib) ? $header_attrib : NULL, $part['headers']); else if ($part['type']=='content') { -// var_dump($part['parameters']); + if (empty($part['parameters']) || empty($part['parameters']['charset'])) + $part['parameters']['charset'] = $MESSAGE['headers']->charset; + // $body = rcmail_print_body($part['body'], $part['ctype_primary'], $part['ctype_secondary'], $part['encoding'], $safe_mode); $body = rcmail_print_body($part, $safe_mode); $out .= '
'; @@ -1078,7 +1089,7 @@ function rcmail_address_string($input, $max=NULL, $addicon=NULL) { $j++; if ($PRINT_MODE) - $out .= sprintf('%s <%s>', htmlentities($part['name']), $part['mailto']); + $out .= sprintf('%s <%s>', rep_specialchars_output($part['name']), $part['mailto']); else if (preg_match($EMAIL_ADDRESS_PATTERN, $part['mailto'])) { $out .= sprintf('%s', @@ -1086,7 +1097,7 @@ function rcmail_address_string($input, $max=NULL, $addicon=NULL) $JS_OBJECT_NAME, $part['mailto'], $part['mailto'], - htmlentities($part['name'])); + rep_specialchars_output($part['name'])); if ($addicon) $out .= sprintf(' add', @@ -1099,7 +1110,7 @@ function rcmail_address_string($input, $max=NULL, $addicon=NULL) else { if ($part['name']) - $out .= htmlentities($part['name']); + $out .= rep_specialchars_output($part['name']); if ($part['mailto']) $out .= (strlen($out) ? ' ' : '') . sprintf('<%s>', $part['mailto']); } diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc index 61821261d..809aed534 100644 --- a/program/steps/mail/sendmail.inc +++ b/program/steps/mail/sendmail.inc @@ -147,9 +147,16 @@ if (is_array($_FILES['_attachments']['tmp_name'])) foreach ($_FILES['_attachments']['tmp_name'] as $i => $filepath) $MAIL_MIME->addAttachment($filepath, $files['type'][$i], $files['name'][$i], TRUE); +// encoding settings for mail composing +$message_param = array('text_encoding' => '7bit', + 'html_encoding' => 'quoted-printable', + 'head_encoding' => 'quoted-printable', + 'head_charset' => 'ISO-8859-1', + 'html_charset' => 'UTF-8', + 'text_charset' => 'UTF-8'); // compose message body and get headers -$msg_body = $MAIL_MIME->get(); +$msg_body = $MAIL_MIME->get($message_param); $msg_subject = $headers['Subject']; diff --git a/program/steps/settings/manage_folders.inc b/program/steps/settings/manage_folders.inc index b960561f7..04b2a461e 100644 --- a/program/steps/settings/manage_folders.inc +++ b/program/steps/settings/manage_folders.inc @@ -19,6 +19,8 @@ */ +require_once('lib/utf7.inc'); + // init IAMP connection rcmail_imap_init(TRUE); @@ -47,7 +49,7 @@ else if ($_action=='unsubscribe') else if ($_action=='create-folder') { if (strlen($_GET['_name'])) - $create = $IMAP->create_mailbox(trim($_GET['_name']), TRUE); + $create = $IMAP->create_mailbox(strip_tags(trim($_GET['_name'])), TRUE); if ($create && $_GET['_remote']) { @@ -122,7 +124,7 @@ function rcube_subscription_form($attrib) $out .= sprintf('%s%s%s', $i+1, $zebra_class, - rep_specialchars_output($folder, 'html'), + rep_specialchars_output(UTF7DecodeString($folder), 'html', 'all'), $checkbox_subscribe->show(in_array($folder, $a_subscribed)?$folder:'', array('value' => $folder)), $JS_OBJECT_NAME, $folder_js, -- cgit v1.2.3