summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c>2009-04-25 18:38:59 +0000
committeralec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c>2009-04-25 18:38:59 +0000
commit687ffe2013521f0ef6a3d6d69578fe111594b7b3 (patch)
tree22a0c988880da4a0b712fee0db097f822e3b75f2
parent0c5998b03560f9ac89447204442100a99499eb61 (diff)
- Fix attachment names encoding when charset isn't specified in attachment part (#1484969):
assume that the message charset or charset of the first part is better for attachment names than detected by roundcube git-svn-id: https://svn.roundcube.net/trunk@2426 208e9e7b-5314-0410-a742-e7e81cd9613c
-rw-r--r--roundcubemail/CHANGELOG1
-rw-r--r--roundcubemail/program/include/rcube_imap.php19
2 files changed, 18 insertions, 2 deletions
diff --git a/roundcubemail/CHANGELOG b/roundcubemail/CHANGELOG
index 6f1bf3072..e77f152fe 100644
--- a/roundcubemail/CHANGELOG
+++ b/roundcubemail/CHANGELOG
@@ -1,6 +1,7 @@
CHANGELOG RoundCube Webmail
===========================
+- Fix attachment names encoding when charset isn't specified in attachment part (#1484969)
- Fix message normal priority problem (#1485820)
- Fix autocomplete spinning wheel does not disappear (#1485804)
- Added log_date_format option (#1485709)
diff --git a/roundcubemail/program/include/rcube_imap.php b/roundcubemail/program/include/rcube_imap.php
index e2b6c0d9a..6226c28c2 100644
--- a/roundcubemail/program/include/rcube_imap.php
+++ b/roundcubemail/program/include/rcube_imap.php
@@ -53,6 +53,7 @@ class rcube_imap
var $delimiter = NULL;
var $caching_enabled = FALSE;
var $default_charset = 'ISO-8859-1';
+ var $struct_charset = NULL;
var $default_folders = array('INBOX');
var $default_folders_lc = array('inbox');
var $fetch_add_headers = '';
@@ -1119,7 +1120,20 @@ class rcube_imap
{
$this->_msg_id = $msg_id;
$headers = $this->get_headers($uid);
-
+
+ // set message charset from message headers
+ if ($headers->charset)
+ $this->struct_charset = $headers->charset;
+ // ... or from first part headers
+ else if (is_array($structure[2]) && $structure[2][0] == 'charset')
+ $this->struct_charset = $structure[2][1];
+ else if (is_array($structure[0][2]) && $structure[0][2][0] == 'charset')
+ $this->struct_charset = $structure[0][2][1];
+ else if (is_array($structure[0][0][2]) && $structure[0][0][2][0] == 'charset')
+ $this->struct_charset = $structure[0][0][2][1];
+ else
+ $this->struct_charset = null;
+
$struct = &$this->_structure_part($structure);
$struct->headers = get_object_vars($headers);
@@ -1364,7 +1378,8 @@ class rcube_imap
// decode filename
if (!empty($filename_mime)) {
$part->filename = rcube_imap::decode_mime_string($filename_mime,
- $part->charset ? $part->charset : rc_detect_encoding($filename_mime, $this->default_charset));
+ $part->charset ? $part->charset : $this->struct_charset ? $this->struct_charset :
+ rc_detect_encoding($filename_mime, $this->default_charset));
}
else if (!empty($filename_encoded)) {
// decode filename according to RFC 2231, Section 4