Fix iCal attendee CN issue

This commit is contained in:
Jörg Lehrke 2010-05-18 10:04:29 +00:00
parent d2c03cd287
commit e8298f217f
2 changed files with 15 additions and 7 deletions

View File

@ -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);

View File

@ -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];