plugins/libkolab
Aleksander Machniak
machniak at kolabsys.com
Tue Nov 6 15:10:29 CET 2012
plugins/libkolab/lib/kolab_format_event.php | 8 ++++----
plugins/libkolab/lib/kolab_storage_folder.php | 19 +++++++++++++++----
2 files changed, 19 insertions(+), 8 deletions(-)
New commits:
commit f7b2e543e29ef277a56bafd2a39c221847379d5d
Author: Aleksander Machniak <machniak at kolabsys.com>
Date: Tue Nov 6 15:09:47 2012 +0100
Fix attachments handling (Bug #1172)
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,
);
}
}
More information about the commits
mailing list