Fix error when opening an attachment from an itip message (#5343)

Also make sure attachment bodies are excluded from the event data in JSON format
This commit is contained in:
Aleksander Machniak 2016-03-09 16:28:52 +01:00
parent b02359a6ce
commit 3ec61b99be
2 changed files with 26 additions and 2 deletions

View file

@ -1742,6 +1742,12 @@ class calendar extends rcube_plugin
foreach ((array)$event['attachments'] as $k => $attachment) {
$event['attachments'][$k]['classname'] = rcube_utils::file2class($attachment['mimetype'], $attachment['name']);
unset($event['attachments'][$k]['data'], $event['attachments'][$k]['content']);
if (!$attachment['id']) {
$event['attachments'][$k]['id'] = $k;
}
}
// convert link URIs references into structs
@ -1892,7 +1898,19 @@ class calendar extends rcube_plugin
$rev = rcube_utils::get_input_value('_rev', rcube_utils::INPUT_GPC);
$event = array('id' => $event_id, 'calendar' => $calendar, 'rev' => $rev);
$attachment = $this->driver->get_attachment($id, $event);
if ($calendar == '--invitation--itip') {
$uid = rcube_utils::get_input_value('_uid', rcube_utils::INPUT_GPC);
$part = rcube_utils::get_input_value('_part', rcube_utils::INPUT_GPC);
$mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_GPC);
$event = $this->lib->mail_get_itip_object($mbox, $uid, $part, 'event');
$attachment = $event['attachments'][$id];
$attachment['body'] = &$attachment['data'];
}
else {
$attachment = $this->driver->get_attachment($id, $event);
}
// show part page
if (!empty($_GET['_frame'])) {
@ -1903,7 +1921,10 @@ class calendar extends rcube_plugin
}
// deliver attachment content
else if ($attachment) {
$attachment['body'] = $this->driver->get_attachment_body($id, $event);
if ($calendar != '--invitation--itip') {
$attachment['body'] = $this->driver->get_attachment_body($id, $event);
}
$this->lib->attachment_get($attachment);
}

View file

@ -335,6 +335,9 @@ function rcube_calendar_ui(settings)
if (event.rev)
query._rev = event.rev;
if (event.calendar == "--invitation--itip")
$.extend(query, {_uid: event._uid, _part: event._part, _mbox: event._mbox});
// open attachment in frame if it's of a supported mimetype
if (id && att.mimetype && $.inArray(att.mimetype, settings.mimetypes)>=0) {
if (rcmail.open_window(rcmail.url('get-attachment', query), true, true)) {