summaryrefslogtreecommitdiff
path: root/program/steps/mail
diff options
context:
space:
mode:
authorthomascube <thomas@roundcube.net>2005-10-21 12:12:23 +0000
committerthomascube <thomas@roundcube.net>2005-10-21 12:12:23 +0000
commita95e0e174c48b7c5242b8969aef99838a52c41ee (patch)
treeeb87cb9c33433269d2f2376e841e1d6d66eff667 /program/steps/mail
parent7902df457d3401c83f78a6ddd48df1a7f07f68b1 (diff)
Improved support for UTF-8 and other charsets
Diffstat (limited to 'program/steps/mail')
-rw-r--r--program/steps/mail/func.inc41
-rw-r--r--program/steps/mail/sendmail.inc9
2 files changed, 34 insertions, 16 deletions
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 .= '<ul>' . rcmail_render_folder_tree_html($folder['folders'], $special, $mbox, $maxlength, $nestLevel+1) . "</ul>\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('<option value="%s">%s%s</option>'."\n",
$folder['id'],
str_repeat('&nbsp;', $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 .= '<div class="message-part">';
@@ -1078,7 +1089,7 @@ function rcmail_address_string($input, $max=NULL, $addicon=NULL)
{
$j++;
if ($PRINT_MODE)
- $out .= sprintf('%s &lt;%s&gt;', htmlentities($part['name']), $part['mailto']);
+ $out .= sprintf('%s &lt;%s&gt;', rep_specialchars_output($part['name']), $part['mailto']);
else if (preg_match($EMAIL_ADDRESS_PATTERN, $part['mailto']))
{
$out .= sprintf('<a href="mailto:%s" onclick="return %s.command(\'compose\',\'%s\',this)" class="rcmContactAddress" title="%s">%s</a>',
@@ -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('&nbsp;<a href="#add" onclick="return %s.command(\'add-contact\',\'%s\',this)" title="%s"><img src="%s%s" alt="add" border="0" /></a>',
@@ -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('&lt;%s&gt;', $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'];