summaryrefslogtreecommitdiff
path: root/program/steps/mail/func.inc
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2012-12-28 12:40:57 +0100
committerAleksander Machniak <alec@alec.pl>2012-12-28 12:40:57 +0100
commitbe72fb3597c21ca3aaa058adf41bb72d53d197c7 (patch)
treef1f77633fb77f105305967b760f7d37a8372409d /program/steps/mail/func.inc
parent8809a1828477101ade03b261662df089e268ecb4 (diff)
Unified attachments filenames handling for message parts without a filename
Diffstat (limited to 'program/steps/mail/func.inc')
-rw-r--r--program/steps/mail/func.inc30
1 files changed, 25 insertions, 5 deletions
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index 814adb64d..bedd3e8ea 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -1598,10 +1598,7 @@ function rcmail_message_part_controls($attrib)
$part = $MESSAGE->mime_parts[$part];
$table = new html_table(array('cols' => 3));
- $filename = $part->filename;
- if (empty($filename) && $attach_prop->mimetype == 'text/html') {
- $filename = rcube_label('htmlmessage');
- }
+ $filename = rcmail_attachment_name($part);
if (!empty($filename)) {
$table->add('title', Q(rcube_label('filename')));
@@ -1616,7 +1613,6 @@ function rcmail_message_part_controls($attrib)
}
-
function rcmail_message_part_frame($attrib)
{
global $MESSAGE;
@@ -1841,6 +1837,30 @@ function rcmail_fix_mimetype($name)
return $name;
}
+// return attachment filename, handle empty filename case
+function rcmail_attachment_name($attachment)
+{
+ $filename = $attachment->filename;
+
+ if ($filename === null || $filename === '') {
+ if ($attachment->mimetype == 'text/html') {
+ $filename = rcube_label('htmlmessage');
+ }
+ else {
+ $ext = rcube_mime::get_mime_extensions($attachment->mimetype);
+ $ext = array_shift($ext);
+ $filename = rcube_label('messagepart') . ' ' . $attachment->mime_id;
+ if ($ext) {
+ $filename .= '.' . $ext;
+ }
+ }
+ }
+
+ $filename = preg_replace('[\r\n]', '', $filename);
+
+ return $filename;
+}
+
function rcmail_search_filter($attrib)
{
global $OUTPUT, $CONFIG;