diff --git a/calendar/inc/class.calendar_ical.inc.php b/calendar/inc/class.calendar_ical.inc.php index f7f29ac5c2..d180b7c7a0 100644 --- a/calendar/inc/class.calendar_ical.inc.php +++ b/calendar/inc/class.calendar_ical.inc.php @@ -481,10 +481,13 @@ class calendar_ical extends calendar_boupdate error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ . '()attendee:' . array2string($info) ."\n",3,$this->logfile); } - $participantCN = '"' . (empty($info['cn']) ? $info['name'] : $info['cn']) . '"'; + $participantCN = trim(empty($info['cn']) ? $info['name'] : $info['cn']); + $participantCN = str_replace(array('\\', ',', ';', ':'), + array('\\\\', '\\,', '\\;', '\\:'), + $participantCN); if ($version == '1.0') { - $participantURL = trim($participantCN . (empty($info['email']) ? '' : ' <' . $info['email'] .'>')); + $participantURL = trim('"' . $participantCN . '"' . (empty($info['email']) ? '' : ' <' . $info['email'] .'>')); } else { @@ -495,7 +498,7 @@ class calendar_ical extends calendar_boupdate { $organizerURL = $participantURL; $organizerCN = $participantCN; - $organizerUID = $uid; + $organizerUID = ($info['type'] != 'e' ? $uid : ''); } $attributes['ATTENDEE'][] = $participantURL; // RSVP={TRUE|FALSE} // resonse expected, not set in eGW => status=U @@ -570,7 +573,10 @@ class calendar_ical extends calendar_boupdate { $attributes['ORGANIZER'] = $organizerURL; $parameters['ORGANIZER']['CN'] = $organizerCN; - $parameters['ORGANIZER']['X-EGROUPWARE-UID'] = $organizerUID; + if (!empty($organizerUID)) + { + $parameters['ORGANIZER']['X-EGROUPWARE-UID'] = $organizerUID; + } } break; @@ -2695,7 +2701,9 @@ class calendar_ical extends calendar_boupdate // ... and for provided CN if (!empty($attributes['params']['CN'])) { - $cn = $attributes['params']['CN']; + $cn = str_replace(array('\\,', '\\;', '\\:', '\\\\'), + array(',', ';', ':', '\\'), + $attributes['params']['CN']); if ($cn[0] == '"' && substr($cn,-1) == '"') { $cn = substr($cn,1,-1); diff --git a/phpgwapi/inc/horde/Horde/iCalendar.php b/phpgwapi/inc/horde/Horde/iCalendar.php index 14c9ba736f..2719cfbf79 100644 --- a/phpgwapi/inc/horde/Horde/iCalendar.php +++ b/phpgwapi/inc/horde/Horde/iCalendar.php @@ -628,14 +628,14 @@ class Horde_iCalendar { // Parse the remaining attributes. if (preg_match_all('/^((?:[^":]+|(?:"[^"]*")+)*):([^\r\n]*)\r?$/m', $vCal, $matches)) { foreach ($matches[0] as $attribute) { - preg_match('/([^;^:]*)((;(?:[^":]+|(?:"[^"]*")+)*)?):([^\r\n]*)[\r\n]*/', $attribute, $parts); + preg_match('/([^:;]*)((;(?:(?:[^":\\\]*(?:\\\.)?)+|(?:"[^"]*")+)*)?):([^\r\n]*)[\r\n]*/', $attribute, $parts); $tag = trim(String::upper($parts[1])); $value = $parts[4]; $params = array(); // Parse parameters. if (!empty($parts[2])) { - preg_match_all('/;(([^;=]*)(=([^;]*))?)/', $parts[2], $param_parts); + preg_match_all('/;(([^;=]*)(=((?:[^;\\\]*(?:\\\.)?)*))?)/', $parts[2], $param_parts); foreach ($param_parts[2] as $key => $paramName) { $paramName = String::upper($paramName); $paramValue = $param_parts[4][$key];