From 4b0f65a597c8339b513bc44e16a95f3803c26369 Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Fri, 18 Nov 2005 10:32:20 -0500
Subject: [PATCH] Fixed minor bugs

---
 CHANGELOG                        |    7 +++
 program/include/rcube_shared.inc |   10 ++++-
 skins/default/mail.css           |    3 +
 program/steps/mail/func.inc      |    6 +-
 program/steps/mail/get.inc       |    7 +++
 config/main.inc.php.dist         |    6 +++
 program/steps/mail/sendmail.inc  |   24 ++++++++++--
 program/localization/index.inc   |    5 +-
 program/include/rcube_imap.inc   |   12 ++++-
 program/steps/mail/move_del.inc  |    2 
 10 files changed, 65 insertions(+), 17 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 6e33704..ae7631f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -60,7 +60,7 @@
 - Display folder names with special chars correctly (Bug #1330157)
 
 
-2005/11/13
+2005/11/18
 ----------
 - Added Finnish, Romanian, Polish, Czech, British, Norwegian, Greek, Russian and Chinese translation
 - Get IMAP server capabilities in array
@@ -82,3 +82,8 @@
 - Added keep-alive signal every minute
 - Make logs dir configurable
 - Added support for SMTPS
+- Decode attachment file names
+- Make delimiter for message headers configurable
+- Add generic footer to sent messages
+
+
diff --git a/config/main.inc.php.dist b/config/main.inc.php.dist
index 2220a57..6a0ada4 100644
--- a/config/main.inc.php.dist
+++ b/config/main.inc.php.dist
@@ -110,6 +110,12 @@
 // default sort order
 $rcmail_config['message_sort_order'] = 'DESC';
 
+// path to a text file which will be added to each sent message
+// paths are relative to the RoundCube root folder
+$rcmail_config['generic_message_footer'] = '';
+
+// this string is used as a delimiter for message headers when sending
+$rcmail_config['mail_header_delimiter'] = "\r\n";
 
 
 /***** these settings can be overwritten by user's preferences *****/
diff --git a/program/include/rcube_imap.inc b/program/include/rcube_imap.inc
index 44ef248..2237b38 100644
--- a/program/include/rcube_imap.inc
+++ b/program/include/rcube_imap.inc
@@ -988,6 +988,12 @@
 
   function decode_header($input)
     {
+    return $this->decode_mime_string($input);
+    }
+    
+    
+  function decode_mime_string($input)
+    {
     $out = '';
 
     $pos = strpos($input, '=?');
@@ -1002,8 +1008,8 @@
       $encstr = substr($input, $pos+2, ($end_pos-$pos-2));
       $rest = substr($input, $end_pos+2);
 
-      $out .= $this->decode_mime_string($encstr);
-      $out .= $this->decode_header($rest);
+      $out .= rcube_imap::_decode_mime_string_part($encstr);
+      $out .= rcube_imap::decode_mime_string($rest);
 
       return $out;
       }
@@ -1012,7 +1018,7 @@
     }
 
 
-  function decode_mime_string($str)
+  function _decode_mime_string_part($str)
     {
     $a = explode('?', $str);
     $count = count($a);
diff --git a/program/include/rcube_shared.inc b/program/include/rcube_shared.inc
index 8d26d56..400e345 100644
--- a/program/include/rcube_shared.inc
+++ b/program/include/rcube_shared.inc
@@ -1208,8 +1208,14 @@
     {
     if (!$html_encode_arr)
       {
-      $html_encode_arr = $CHARSET=='ISO-8859-1' ? get_html_translation_table(HTML_ENTITIES) : get_html_translation_table(HTML_SPECIALCHARS);
-      $html_encode_arr[chr(128)] = '&euro;';
+      if ($CHARSET=='ISO-8859-1')
+        {
+        $html_encode_arr = get_html_translation_table(HTML_ENTITIES);
+        $html_encode_arr[chr(128)] = '&euro;';
+        }
+      else
+        $html_encode_arr = get_html_translation_table(HTML_SPECIALCHARS);
+        
       unset($html_encode_arr['?']);
       unset($html_encode_arr['&']);
       }
diff --git a/program/localization/index.inc b/program/localization/index.inc
index a0c6671..3386ebd 100644
--- a/program/localization/index.inc
+++ b/program/localization/index.inc
@@ -37,7 +37,7 @@
 	'el'    => 'Greek',
 	'hu'    => 'Hungarian',
 	'it'    => 'Italiano',
-	'jp'    => 'Japanese',
+	'ja'    => 'Japanese',
 	'kr'    => 'Korean',
 	'lv'    => 'Latvian',
 	'nl'    => 'Nederlands',
@@ -63,7 +63,8 @@
 	'lv' => 'ISO-8859-2',
 	'pl' => 'ISO-8859-2',
 	'el' => 'ISO-8859-7',
-	'tw' => 'BIG5'
+	'tw' => 'BIG5',
+	'ja' => 'UTF-8'
 );
 
 ?>
\ No newline at end of file
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index 4d80c85..ca72f74 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -797,13 +797,13 @@
                (empty($mail_part->disposition) && ($mail_part->d_parameters['filename'] || $mail_part->d_parameters['name'])))
         {
         if ($message_ctype_secondary=='related' && $mail_part->headers['content-id'])
-          $sa_inline_objects[] = array('filename' => $mail_part->d_parameters['filename'],
+          $sa_inline_objects[] = array('filename' => rcube_imap::decode_mime_string($mail_part->d_parameters['filename']),
                                        'mimetype' => strtolower("$primary_type/$secondary_type"),
                                        'part_id'  => $mail_part->mime_id,
                                        'content_id' => preg_replace(array('/^</', '/>$/'), '', $mail_part->headers['content-id']));
 
         else if ($mail_part->d_parameters['filename'])
-          $a_attachments[] = array('filename' => $mail_part->d_parameters['filename'],
+          $a_attachments[] = array('filename' => rcube_imap::decode_mime_string($mail_part->d_parameters['filename']),
                                    'encoding' => strtolower($mail_part->headers['content-transfer-encoding']),
                                    'mimetype' => strtolower("$primary_type/$secondary_type"),
                                    'part_id'  => $mail_part->mime_id,
@@ -811,7 +811,7 @@
                                    'content'  => $mail_part->body */);
                                    
         else if ($mail_part->ctype_parameters['name'])
-          $a_attachments[] = array('filename' => $mail_part->ctype_parameters['name'],
+          $a_attachments[] = array('filename' => rcube_imap::decode_mime_string($mail_part->ctype_parameters['name']),
                                    'encoding' => strtolower($mail_part->headers['content-transfer-encoding']),
                                    'mimetype' => strtolower("$primary_type/$secondary_type"),
                                    'part_id'  => $mail_part->mime_id,
diff --git a/program/steps/mail/get.inc b/program/steps/mail/get.inc
index 9a86177..fc6d99d 100644
--- a/program/steps/mail/get.inc
+++ b/program/steps/mail/get.inc
@@ -99,6 +99,13 @@
 
     header(sprintf('Content-Length: %d', strlen($cont)));
 
+    // We need to set the following headers to make downloads work using IE in HTTPS mode.
+    if (isset($_SERVER['HTTPS']))
+      {
+      header('Pragma: ');
+      header('Cache-Control: ');
+      }
+
     // deliver part content
     echo $cont;
     exit;
diff --git a/program/steps/mail/move_del.inc b/program/steps/mail/move_del.inc
index 41b11d5..e3c7549 100644
--- a/program/steps/mail/move_del.inc
+++ b/program/steps/mail/move_del.inc
@@ -77,7 +77,7 @@
 // add new rows from next page (if any)
 if ($_GET['_from']!='show' && $pages>1 && $IMAP->list_page < $pages)
   {
-  $a_headers = $IMAP->list_headers($mbox);
+  $a_headers = $IMAP->list_headers($mbox, null, $_SESSION['sort_col'], $_SESSION['sort_order']);
   $a_headers = array_slice($a_headers, -$count, $count);
   $commands .= rcmail_js_message_list($a_headers);
   }
diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc
index 4d7afb5..4531aa3 100644
--- a/program/steps/mail/sendmail.inc
+++ b/program/steps/mail/sendmail.inc
@@ -137,8 +137,24 @@
   $headers['User-Agent'] = $CONFIG['useragent'];
 
 
+// append generic footer to all messages
+if (!empty($CONFIG['generic_message_footer']))
+  {
+  $file = realpath($CONFIG['generic_message_footer']);
+  if($fp = fopen($file, 'r'))
+    {
+    $content = fread($fp, filesize($file));
+    fclose($fp);
+    $_POST['_message'] .= "\r\n" . $content;
+    }
+  }
+
+
+// use the configured delimiter for headers
+$header_delm = $rcmail_config['mail_header_delimiter'] ? $rcmail_config['mail_header_delimiter'] : "\r\n";
+
 // create PEAR::Mail_mime instance
-$MAIL_MIME = new Mail_mime("\n");
+$MAIL_MIME = new Mail_mime($header_delm);
 $MAIL_MIME->setTXTBody(stripslashes($_POST['_message']), FALSE, TRUE);
 //$MAIL_MIME->setTXTBody(wordwrap(stripslashes($_POST['_message'])), FALSE, TRUE);
 
@@ -158,9 +174,9 @@
 $message_param = array('text_encoding' => '7bit',
                        'html_encoding' => 'quoted-printable',
                        'head_encoding' => 'quoted-printable',
-                       'head_charset'  => 'ISO-8859-1',
-                       'html_charset'  => 'ISO-8859-1',
-                       'text_charset'  => 'ISO-8859-1');
+                       'head_charset'  => $CHARSET,
+                       'html_charset'  => $CHARSET,
+                       'text_charset'  => $CHARSET);
 
 // compose message body and get headers
 $msg_body = $MAIL_MIME->get($message_param);
diff --git a/skins/default/mail.css b/skins/default/mail.css
index 5a362c1..f429407 100644
--- a/skins/default/mail.css
+++ b/skins/default/mail.css
@@ -339,8 +339,9 @@
   padding: 2px;
   padding-right: 4px;
   font-size: 11px;
-  overflow: hidden;  
+  overflow: hidden;
   white-space: nowrap;
+  text-overflow: ellipsis;
   border-bottom: 1px solid #EBEBEB;
   cursor: pointer;
 }

--
Gitblit v1.9.1