Fix attachments handling (Bug #1172)

This commit is contained in:
Aleksander Machniak 2012-11-06 15:09:47 +01:00
parent a5e723d3d7
commit f7b2e543e2
2 changed files with 19 additions and 8 deletions

View file

@ -143,14 +143,14 @@ class kolab_format_event extends kolab_format_xcal
$attach = $vattach->get($i); $attach = $vattach->get($i);
// skip cid: attachments which are mime message parts handled by kolab_storage_folder // 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(); $name = $attach->label();
$data = $attach->data(); $data = $attach->data();
$object['_attachments'][$name] = array( $object['_attachments'][$name] = array(
'name' => $name, 'name' => $name,
'mimetype' => $attach->mimetype(), 'mimetype' => $attach->mimetype(),
'size' => strlen($data), 'size' => strlen($data),
'content' => $data, 'content' => $data,
); );
} }
} }

View file

@ -445,12 +445,23 @@ class kolab_storage_folder
$xml = $part->body ? $part->body : $message->get_part_content($part->mime_id); $xml = $part->body ? $part->body : $message->get_part_content($part->mime_id);
} }
else if ($part->filename || $part->content_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( $attachments[$key] = array(
'id' => $part->mime_id, 'id' => $part->mime_id,
'name' => $part->filename, 'name' => $part->filename,
'mimetype' => $part->mimetype, 'mimetype' => $part->mimetype,
'size' => $part->size, 'size' => $size,
); );
} }
} }