diff options
author | Aleksander Machniak <machniak@kolabsys.com> | 2012-11-06 14:09:47 (GMT) |
---|---|---|
committer | Aleksander Machniak <machniak@kolabsys.com> | 2012-11-06 14:09:47 (GMT) |
commit | f7b2e543e29ef277a56bafd2a39c221847379d5d (patch) | |
tree | 4665978ea2b2da3e9454878a6481a4d58c7bdbc5 | |
parent | a5e723d3d7509edeb448e92505e96bed7e4f4efe (diff) | |
download | roundcubemail-plugins-kolab-f7b2e543e29ef277a56bafd2a39c221847379d5d.tar.gz |
Fix attachments handling (Bug #1172)
-rw-r--r-- | plugins/libkolab/lib/kolab_format_event.php | 8 | ||||
-rw-r--r-- | plugins/libkolab/lib/kolab_storage_folder.php | 19 |
2 files changed, 19 insertions, 8 deletions
diff --git a/plugins/libkolab/lib/kolab_format_event.php b/plugins/libkolab/lib/kolab_format_event.php index 33ed5af..90bfea3 100644 --- a/plugins/libkolab/lib/kolab_format_event.php +++ b/plugins/libkolab/lib/kolab_format_event.php @@ -143,14 +143,14 @@ class kolab_format_event extends kolab_format_xcal $attach = $vattach->get($i); // skip cid: attachments which are mime message parts handled by kolab_storage_folder - if (substr($attach->uri(), 0, 4) != 'cid') { + if (substr($attach->uri(), 0, 4) != 'cid:') { $name = $attach->label(); $data = $attach->data(); $object['_attachments'][$name] = array( - 'name' => $name, + 'name' => $name, 'mimetype' => $attach->mimetype(), - 'size' => strlen($data), - 'content' => $data, + 'size' => strlen($data), + 'content' => $data, ); } } diff --git a/plugins/libkolab/lib/kolab_storage_folder.php b/plugins/libkolab/lib/kolab_storage_folder.php index 08bf669..461125b 100644 --- a/plugins/libkolab/lib/kolab_storage_folder.php +++ b/plugins/libkolab/lib/kolab_storage_folder.php @@ -445,12 +445,23 @@ class kolab_storage_folder $xml = $part->body ? $part->body : $message->get_part_content($part->mime_id); } else if ($part->filename || $part->content_id) { - $key = $part->content_id ? trim($part->content_id, '<>') : $part->filename; + $key = $part->content_id ? trim($part->content_id, '<>') : $part->filename; + $size = null; + + // Use Content-Disposition 'size' as for the Kolab Format spec. + if (isset($part->d_parameters['size'])) { + $size = $part->d_parameters['size']; + } + // we can trust part size only if it's not encoded + else if ($part->encoding == 'binary' || $part->encoding == '7bit' || $part->encoding == '8bit') { + $size = $part->size; + } + $attachments[$key] = array( - 'id' => $part->mime_id, - 'name' => $part->filename, + 'id' => $part->mime_id, + 'name' => $part->filename, 'mimetype' => $part->mimetype, - 'size' => $part->size, + 'size' => $size, ); } } |