diff options
-rw-r--r-- | program/include/rcube_imap.inc | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/program/include/rcube_imap.inc b/program/include/rcube_imap.inc index f7584041a..dce778968 100644 --- a/program/include/rcube_imap.inc +++ b/program/include/rcube_imap.inc @@ -1145,10 +1145,14 @@ class rcube_imap } // normalize filename property - if (!empty($struct->d_parameters['filename'])) - $struct->filename = $this->decode_mime_string($struct->d_parameters['filename']); - else if (!empty($struct->ctype_parameters['name'])) - $struct->filename = $this->decode_mime_string($struct->ctype_parameters['name']); + if ($filename_mime = $struct->d_parameters['filename'] ? $struct->d_parameters['filename'] : $struct->ctype_parameters['name']) + $struct->filename = $this->decode_mime_string($filename_mime); + else if ($filename_encoded = $struct->d_parameters['filename*'] ? $struct->d_parameters['filename*'] : $struct->ctype_parameters['name*']) + { + // decode filename according to RFC 2231, Section 4 + list($filename_charset,, $filename_urlencoded) = split('\'', $filename_encoded); + $struct->filename = rcube_charset_convert(urldecode($filename_urlencoded), $filename_charset); + } else if (!empty($struct->headers['content-description'])) $struct->filename = $this->decode_mime_string($struct->headers['content-description']); |