Index: pontomail.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/pontomail/pontomail.module,v
retrieving revision 1.32
diff -u -r1.32 pontomail.module
--- pontomail.module 5 Oct 2006 21:25:50 -0000 1.32
+++ pontomail.module 15 Oct 2006 17:59:42 -0000
@@ -629,13 +629,15 @@
'#value' => l($date, $msg_link),
'#prefix' => $prefix, '#suffix' => $suffix
);
+ $msg_from = decode_header($msg->from);
$form['mail_actions']['messages'][$msg->uid]['from'] = array(
- '#value' => l(strlen($msg->from) > $WIDTH_LIMIT ? substr($msg->from, 0,$WIDTH_LIMIT - 3) . '...' : $msg->from,
+ '#value' => l(strlen($msg_from) > $WIDTH_LIMIT ? substr($msg_from, 0,$WIDTH_LIMIT - 3) . '...' : $msg_from,
$msg_link),
'#prefix' => $prefix, '#suffix' => $suffix
);
+ $msg_subject = decode_header($msg->subject);
$form['mail_actions']['messages'][$msg->uid]['subject'] = array(
- '#value' => strlen($msg->subject) > $WIDTH_LIMIT ? substr($msg->subject, 0,$WIDTH_LIMIT - 3) . '...' : $msg->subject,
+ '#value' => strlen($msg_subject) > $WIDTH_LIMIT ? substr($msg_subject, 0,$WIDTH_LIMIT - 3) . '...' : $msg_subject,
'#prefix' => $prefix, '#suffix' => $suffix
);
$form['mail_actions']['messages'][$msg->uid]['size'] = array(
@@ -871,9 +873,9 @@
format_date(strtotime($message_obj->headers->MailDate), 'custom', 'F j, Y ')
. strftime("%I:%M %p", strtotime($message_obj->headers->MailDate))
. "";
- $page .= "
From: " . htmlspecialchars($message_obj->headers->fromaddress) . "";
- $page .= "
To: " . htmlspecialchars($message_obj->headers->toaddress) . "";
- $page .= "
Subject: " . htmlspecialchars($message_obj->headers->Subject) . "";
+ $page .= "
From: " . htmlspecialchars(decode_header($message_obj->headers->fromaddress)) . "";
+ $page .= "
To: " . htmlspecialchars(decode_header($message_obj->headers->toaddress)) . "";
+ $page .= "
Subject: " . htmlspecialchars(decode_header($message_obj->headers->Subject)) . "";
$page .= "
";
# Attachement Grouping
@@ -1565,5 +1567,67 @@
return '\n";
}
+function decode_header($input) {
+ $out = '';
+
+ $pos = strpos($input, '=?');
+ if ($pos !== false) {
+ $out = substr($input, 0, $pos);
+
+ $end_cs_pos = strpos($input, "?", $pos+2);
+ $end_en_pos = strpos($input, "?", $end_cs_pos+1);
+ $end_pos = strpos($input, "?=", $end_en_pos+1);
+
+ $encstr = substr($input, $pos+2, ($end_pos-$pos-2));
+ $rest = substr($input, $end_pos+2);
+
+ $out .= _decode_mime_string_part($encstr);
+ $out .= decode_header($rest);
+ return $out;
+ }
+ else {
+ return $input;
+ }
+}
+
+function _decode_mime_string_part($str) {
+ $a = explode('?', $str);
+ $count = count($a);
+
+ // should be in format "charset?encoding?base64_string"
+ if ($count >= 3) {
+ for ($i=2; $i<$count; $i++) {
+ $rest.=$a[$i];
+ }
+
+ if (($a[1]=="B")||($a[1]=="b")) {
+ $rest = base64_decode($rest);
+ }
+ else if (($a[1]=="Q")||($a[1]=="q")) {
+ $rest = str_replace("_", " ", $rest);
+ $rest = quoted_printable_decode($rest);
+ }
+ return charset_convert($rest, $a[0]);
+ }
+ else {
+ return $str; // we dont' know what to do with this
+ }
+}
+
+function charset_convert($str, $from, $to=NULL) {
+ $from = strtoupper($from);
+ $to = $to==NULL ? 'UTF-8' : strtoupper($to);
+
+ if ($from==$to) {
+ return $str;
+ }
+
+ // convert charset using iconv module
+ if (function_exists('iconv')) {
+ return iconv($from, $to, $str);
+ }
+
+ return $str;
+}
?>
Index: pontomail_sendmail.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/pontomail/pontomail_sendmail.module,v
retrieving revision 1.25
diff -u -r1.25 pontomail_sendmail.module
--- pontomail_sendmail.module 5 Oct 2006 08:59:41 -0000 1.25
+++ pontomail_sendmail.module 15 Oct 2006 17:59:46 -0000
@@ -361,6 +361,7 @@
$form['sid'] = array('#type' => 'hidden', '#value' => $sid);
}
$form['from'] = array('#type' => 'item', '#title' => t('From'), '#value' => $user_email);
+ $from = ($fwd) ? '' : decode_header($from);
$form['to'] = array('#type' => 'textfield',
'#title' => t('To'),
'#default_value' => $from,
@@ -369,7 +370,7 @@
'#description' => t('Seperate multiple email addresses with a comma (,). Also,
please not that entires that were found via LDAP and are not local to Drupal will be show with
an * in front of them. This is only availiable if you have javascript enabled.'));
- $form['subject'] = array('#type' => 'textfield', '#title' => t('Subject'), '#maxlength' => 50, '#required' => TRUE, '#default_value' => $subject);
+ $form['subject'] = array('#type' => 'textfield', '#title' => t('Subject'), '#maxlength' => 50, '#required' => TRUE, '#default_value' => decode_header($subject));
$form['message'] = array('#type' => 'textarea',
'#title' => t('Message'),
'#rows' => 15, '#required' => TRUE,