From 4c21f5b19e09f931ec2caa2535b8a93f195a6e60 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 29 Sep 2015 07:38:09 +0000 Subject: [PATCH] multiple fixes around managed attachments and new Horde_Icalendar: - no longer decodes base64 automatic - size param have to be string due to bug in handling of integers in Horde_Icalendar - allow stripping of non-binary (eg. text/plain) inline attachments - only add X-EGROUPWARE-ATTACH-INCLUDED, if we have a real managed attachment - store external / url attachments as other unsupported attributes --- calendar/inc/class.calendar_ical.inc.php | 3 +++ phpgwapi/inc/class.groupdav.inc.php | 13 +++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/calendar/inc/class.calendar_ical.inc.php b/calendar/inc/class.calendar_ical.inc.php index 052652cdb2..cb4ab1a13e 100644 --- a/calendar/inc/class.calendar_ical.inc.php +++ b/calendar/inc/class.calendar_ical.inc.php @@ -2978,6 +2978,9 @@ class calendar_ical extends calendar_boupdate case 'X-LIC-ERROR': // parse errors from libical, makes no sense to store them break; + case 'ATTACH': + if ($attributes['params'] && !empty($attributes['params']['FMTTYPE'])) break; // handeled by managed attachment code + // fall throught to store external attachment url default: // X- attribute or other by EGroupware unsupported property //error_log(__METHOD__."() $attributes[name] = ".array2string($attributes)); // for attributes with multiple values in multiple lines, merge the values diff --git a/phpgwapi/inc/class.groupdav.inc.php b/phpgwapi/inc/class.groupdav.inc.php index 519535a117..84c2040672 100644 --- a/phpgwapi/inc/class.groupdav.inc.php +++ b/phpgwapi/inc/class.groupdav.inc.php @@ -1382,10 +1382,11 @@ class groupdav extends HTTP_WebDAV_Server // turn inline attachments into managed ones foreach($attach as $key => $attr) { - if ($attr['params']['VALUE'] === 'BINARY') + if (!empty($attr['params']['FMTTYPE'])) { if (!($to = self::fopen_attachment($app, $id, $filename=$attr['params']['FILENAME'], $attr['params']['FMTTYPE'], $path)) || - ($copied=fwrite($to, $attr['value'])) === false) + // Horde Icalendar does NOT decode automatic + ($copied=fwrite($to, $attr['params']['ENCODING'] == 'BASE64' ? base64_decode($attr['value']) : $attr['value'])) === false) { error_log(__METHOD__."('$app', $id, ...) failed to add attachment ".array2string($attr).") "); continue; @@ -1484,13 +1485,13 @@ class groupdav extends HTTP_WebDAV_Server $parameters['ATTACH'][] = array( 'MANAGED-ID' => groupdav::path2managed_id($path), 'FMTTYPE' => $stat['mime'], - 'SIZE' => $stat['size'], + 'SIZE' => (string)$stat['size'], // Horde_Icalendar renders int as empty string 'FILENAME' => egw_vfs::basename($path), ); + // if we have attachments, set X-attribute to enable deleting them by put + // (works around events synced before without ATTACH attributes) + $attributes['X-EGROUPWARE-ATTACH-INCLUDED'] = 'TRUE'; } - // if we have attachments, set X-attribute to enable deleting them by put - // (works around events synced before without ATTACH attributes) - if ($attributes['ATTACH']) $attributes['X-EGROUPWARE-ATTACH-INCLUDED'] = 'TRUE'; } /**