diff --git a/addressbook/inc/class.addressbook_vcal.inc.php b/addressbook/inc/class.addressbook_vcal.inc.php index 55bb1c1b0b..4723c7bcf5 100644 --- a/addressbook/inc/class.addressbook_vcal.inc.php +++ b/addressbook/inc/class.addressbook_vcal.inc.php @@ -219,6 +219,12 @@ class addressbook_vcal extends addressbook_bo { $size = $this->clientProperties[$vcardField]['Size']; $noTruncate = $this->clientProperties[$vcardField]['NoTruncate']; + if ($this->log && $size > 0) + { + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ . + "() $vcardField Size: $size, NoTruncate: " . + ($noTruncate ? 'TRUE' : 'FALSE') . "\n",3,$this->logfile); + } //Horde::logMessage("vCalAddressbook $vcardField Size: $size, NoTruncate: " . // ($noTruncate ? 'TRUE' : 'FALSE'), __FILE__, __LINE__, PEAR_LOG_DEBUG); } @@ -292,7 +298,11 @@ class addressbook_vcal extends addressbook_bo $value = $values[0]; if (strlen($value) > $size) { - error_log(__FILE__ . __LINE__ . __METHOD__ . " vCalAddressbook $vcardField omitted due to maximum size $size"); + if ($this->log) + { + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ . + "() $vcardField omitted due to maximum size $size\n",3,$this->logfile); + } // Horde::logMessage("vCalAddressbook $vcardField omitted due to maximum size $size", // __FILE__, __LINE__, PEAR_LOG_WARNING); continue; @@ -332,7 +342,11 @@ class addressbook_vcal extends addressbook_bo { if ($noTruncate) { - error_log(__FILE__ . __LINE__ . __METHOD__ . " vCalAddressbook $vcardField omitted due to maximum size $size"); + if ($this->log) + { + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ . + "() $vcardField omitted due to maximum size $size\n",3,$this->logfile); + } // Horde::logMessage("vCalAddressbook $vcardField omitted due to maximum size $size", // __FILE__, __LINE__, PEAR_LOG_WARNING); continue; @@ -348,7 +362,11 @@ class addressbook_vcal extends addressbook_bo { $value = ''; } - error_log(__FILE__ . __LINE__ . __METHOD__ . " vCalAddressbook $vcardField truncated to maximum size $size"); + if ($this->log) + { + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ . + "() $vcardField truncated to maximum size $size\n",3,$this->logfile); + } //Horde::logMessage("vCalAddressbook $vcardField truncated to maximum size $size", // __FILE__, __LINE__, PEAR_LOG_INFO); } @@ -371,10 +389,6 @@ class addressbook_vcal extends addressbook_bo } elseif ($this->productManufacturer == 'funambol') { - if ($this->productName == 'mozilla sync client') - { - $valueData = str_replace( "\n", '\\n', $valueData); - } $options['ENCODING'] = 'FUNAMBOL-QP'; } elseif (preg_match('/([\000-\012\015\016\020-\037\075])/', $value)) @@ -683,8 +697,6 @@ class addressbook_vcal extends addressbook_bo // E.g. ADR will be either ADR;WORK, if no ADR;WORK is given, // or else ADR;HOME, if not available elsewhere. - //error_log(print_r($rowNames, true)); - $finalRowNames = array(); foreach ($rowNames as $vcardKey => $rowName) @@ -836,9 +848,6 @@ class addressbook_vcal extends addressbook_bo array2string($finalRowNames)."\n",3,$this->logfile); } - //error_log(print_r($finalRowNames, true)); - - $contact = array(); foreach ($finalRowNames as $key => $vcardKey) diff --git a/calendar/inc/class.calendar_ical.inc.php b/calendar/inc/class.calendar_ical.inc.php index 6d6b090f73..2fabae275c 100644 --- a/calendar/inc/class.calendar_ical.inc.php +++ b/calendar/inc/class.calendar_ical.inc.php @@ -583,8 +583,14 @@ class calendar_ical extends calendar_boupdate { $size = $this->clientProperties[$icalFieldName]['Size']; $noTruncate = $this->clientProperties[$icalFieldName]['NoTruncate']; - #Horde::logMessage("vCalendar $icalFieldName Size: $size, NoTruncate: " . - # ($noTruncate ? 'TRUE' : 'FALSE'), __FILE__, __LINE__, PEAR_LOG_DEBUG); + if ($this->log && $size > 0) + { + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ . + "() $icalFieldName Size: $size, NoTruncate: " . + ($noTruncate ? 'TRUE' : 'FALSE') . "\n",3,$this->logfile); + } + //Horde::logMessage("vCalendar $icalFieldName Size: $size, NoTruncate: " . + // ($noTruncate ? 'TRUE' : 'FALSE'), __FILE__, __LINE__, PEAR_LOG_DEBUG); } else { @@ -597,14 +603,24 @@ class calendar_ical extends calendar_boupdate { if ($noTruncate) { - Horde::logMessage("vCalendar $icalFieldName omitted due to maximum size $size", - __FILE__, __LINE__, PEAR_LOG_WARNING); + if ($this->log) + { + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ . + "() $icalFieldName omitted due to maximum size $size\n",3,$this->logfile); + } + //Horde::logMessage("vCalendar $icalFieldName omitted due to maximum size $size", + // __FILE__, __LINE__, PEAR_LOG_WARNING); continue; // skip field } // truncate the value to size $value = substr($value, 0, $size - 1); - Horde::logMessage("vCalendar $icalFieldName truncated to maximum size $size", - __FILE__, __LINE__, PEAR_LOG_INFO); + if ($this->log) + { + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ . + "() $icalFieldName truncated to maximum size $size\n",3,$this->logfile); + } + //Horde::logMessage("vCalendar $icalFieldName truncated to maximum size $size", + // __FILE__, __LINE__, PEAR_LOG_INFO); } if (!empty($value) || ($size >= 0 && !$noTruncate)) { @@ -706,12 +722,11 @@ class calendar_ical extends calendar_boupdate $GLOBALS['egw']->translation->charset(),'UTF-8'); $valuesData = (array) $GLOBALS['egw']->translation->convert($values[$key], $GLOBALS['egw']->translation->charset(),'UTF-8'); - //echo "$key:$valueID: value=$valueData, param=".print_r($paramDate,true)."\n"; - // attendees or organizer CN can contain utf-8 content - $paramData['CHARSET'] = 'UTF-8'; + if (preg_match('/[^\x20-\x7F]/', $valueData) || ($paramData['CN'] && preg_match('/[^\x20-\x7F]/', $paramData['CN']))) { + $paramData['CHARSET'] = 'UTF-8'; switch ($this->productManufacturer) { case 'groupdav': @@ -733,13 +748,10 @@ class calendar_ical extends calendar_boupdate } break; case 'funambol': - if ($this->productName == 'mozilla sync client') - { - $valueData = str_replace( "\n", '\\n', $valueData); - } $paramData['ENCODING'] = 'FUNAMBOL-QP'; } } + /* if (preg_match('/([\000-\012])/', $valueData)) { if ($this->log) @@ -748,6 +760,7 @@ class calendar_ical extends calendar_boupdate "() Has invalid XML data: $valueData",3,$this->logfile); } } + */ $vevent->setAttribute($key, $valueData, $paramData, true, $valuesData); } } @@ -1334,7 +1347,6 @@ class calendar_ical extends calendar_boupdate 'owner' => 'owner', 'category' => 'category', 'non_blocking' => 'non_blocking', - 'recurrence' => 'recurrence', ); $defaultFields['evolution'] = $defaultFields['basic'] + array( diff --git a/infolog/inc/class.infolog_ical.inc.php b/infolog/inc/class.infolog_ical.inc.php index a96dcae93b..62bc3bb19e 100644 --- a/infolog/inc/class.infolog_ical.inc.php +++ b/infolog/inc/class.infolog_ical.inc.php @@ -170,8 +170,14 @@ class infolog_ical extends infolog_bo { $size = $this->clientProperties[$field]['Size']; $noTruncate = $this->clientProperties[$field]['NoTruncate']; - #Horde::logMessage("VTODO $field Size: $size, NoTruncate: " . - # ($noTruncate ? 'TRUE' : 'FALSE'), __FILE__, __LINE__, PEAR_LOG_DEBUG); + if ($this->log && $size > 0) + { + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ . + "() $field Size: $size, NoTruncate: " . + ($noTruncate ? 'TRUE' : 'FALSE') . "\n",3,$this->logfile); + } + //Horde::logMessage("VTODO $field Size: $size, NoTruncate: " . + // ($noTruncate ? 'TRUE' : 'FALSE'), __FILE__, __LINE__, PEAR_LOG_DEBUG); } else { @@ -183,30 +189,40 @@ class infolog_ical extends infolog_bo { if ($noTruncate) { - Horde::logMessage("VTODO $field omitted due to maximum size $size", - __FILE__, __LINE__, PEAR_LOG_WARNING); + if ($this->log) + { + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ . + "() $field omitted due to maximum size $size\n",3,$this->logfile); + } + //Horde::logMessage("VTODO $field omitted due to maximum size $size", + // __FILE__, __LINE__, PEAR_LOG_WARNING); continue; // skip field } // truncate the value to size $value = substr($value, 0, $size -1); - #Horde::logMessage("VTODO $field truncated to maximum size $size", - # __FILE__, __LINE__, PEAR_LOG_INFO); + if ($this->log) + { + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ . + "() $field truncated to maximum size $size\n",3,$this->logfile); + } + //Horde::logMessage("VTODO $field truncated to maximum size $size", + // __FILE__, __LINE__, PEAR_LOG_INFO); } if (empty($value) && ($size < 0 || $noTruncate)) continue; if ($field == 'RELATED-TO') { - $options = array('RELTYPE' => 'PARENT', - 'CHARSET' => 'UTF-8'); + $options = array('RELTYPE' => 'PARENT'); } else { - $options = array('CHARSET' => 'UTF-8'); + $options = array(); } if (preg_match('/[^\x20-\x7F]/', $value)) { + $options['CHARSET'] = 'UTF-8'; switch ($this->productManufacturer) { case 'groupdav': @@ -229,10 +245,6 @@ class infolog_ical extends infolog_bo } break; case 'funambol': - if ($this->productName == 'mozilla sync client') - { - $value = str_replace( "\n", '\\n', $value); - } $options['ENCODING'] = 'FUNAMBOL-QP'; } } @@ -268,7 +280,7 @@ class infolog_ical extends infolog_bo } else { - $priority = (int) $this->priority_egw2ical2[$taskData['info_priority']]; + $priority = (int) $this->priority_egw2ical[$taskData['info_priority']]; } $vevent->setAttribute('PRIORITY', $priority); @@ -584,9 +596,10 @@ class infolog_ical extends infolog_bo 'CATEGORIES' => $note['info_cat'], ) as $field => $value) { - $options = array('CHARSET' => 'UTF-8'); + $options = array(); if (preg_match('/[^\x20-\x7F]/', $value)) { + $options['CHARSET'] = 'UTF-8'; switch ($this->productManufacturer) { case 'groupdav': @@ -609,10 +622,6 @@ class infolog_ical extends infolog_bo } break; case 'funambol': - if ($this->productName == 'mozilla sync client') - { - $value = str_replace( "\n", '\\n', $value); - } $options['ENCODING'] = 'FUNAMBOL-QP'; } } diff --git a/phpgwapi/inc/horde/Horde/iCalendar.php b/phpgwapi/inc/horde/Horde/iCalendar.php index 0176e0073f..4850c85162 100644 --- a/phpgwapi/inc/horde/Horde/iCalendar.php +++ b/phpgwapi/inc/horde/Horde/iCalendar.php @@ -649,224 +649,224 @@ class Horde_iCalendar { if (isset($params['BASE64'])) { $params['ENCODING'] = 'BASE64'; } - if (isset($params['ENCODING'])) { - switch (String::upper($params['ENCODING'])) { - case 'Q': - case 'QUOTED-PRINTABLE': - $value = quoted_printable_decode($value); - if (isset($params['CHARSET'])) { - $value = $GLOBALS['egw']->translation->convert($value, $params['CHARSET']); - } else { - $value = $GLOBALS['egw']->translation->convert($value, - empty($charset) ? ($this->isOldFormat() ? 'iso-8859-1' : 'utf-8') : $charset); - } - // Funambol hack :-( - $value = str_replace('\\\\n', "\n", $value); - break; - case 'B': - case 'BASE64': - $value = base64_decode($value); - break; - } - } elseif (isset($params['CHARSET'])) { - $value = $GLOBALS['egw']->translation->convert($value, $params['CHARSET']); - } else { - // As per RFC 2279, assume UTF8 if we don't have an - // explicit charset parameter. - $value = $GLOBALS['egw']->translation->convert($value, - empty($charset) ? ($this->isOldFormat() ? 'iso-8859-1' : 'utf-8') : $charset); - } + if (isset($params['ENCODING'])) { + switch (String::upper($params['ENCODING'])) { + case 'Q': + case 'QUOTED-PRINTABLE': + $value = quoted_printable_decode($value); + if (isset($params['CHARSET'])) { + $value = $GLOBALS['egw']->translation->convert($value, $params['CHARSET']); + } else { + $value = $GLOBALS['egw']->translation->convert($value, + empty($charset) ? ($this->isOldFormat() ? 'iso-8859-1' : 'utf-8') : $charset); + } + // Funambol hack :-( + $value = str_replace('\\\\n', "\n", $value); + break; + case 'B': + case 'BASE64': + $value = base64_decode($value); + break; + } + } elseif (isset($params['CHARSET'])) { + $value = $GLOBALS['egw']->translation->convert($value, $params['CHARSET']); + } else { + // As per RFC 2279, assume UTF8 if we don't have an + // explicit charset parameter. + $value = $GLOBALS['egw']->translation->convert($value, + empty($charset) ? ($this->isOldFormat() ? 'iso-8859-1' : 'utf-8') : $charset); + } - // Get timezone info for date fields from $params. - $tzid = isset($params['TZID']) ? trim($params['TZID'], '\"') : false; + // Get timezone info for date fields from $params. + $tzid = isset($params['TZID']) ? trim($params['TZID'], '\"') : false; - switch ($tag) { - case 'VERSION': // already processed + switch ($tag) { + case 'VERSION': // already processed + break; + // Date fields. + case 'COMPLETED': + case 'CREATED': + case 'LAST-MODIFIED': + $this->setAttribute($tag, $this->_parseDateTime($value, $tzid), $params); + break; + + case 'BDAY': + case 'X-SYNCJE-ANNIVERSARY': + $this->setAttribute($tag, $value, $params, true, $this->_parseDate($value)); + break; + + case 'DTEND': + case 'DTSTART': + case 'DTSTAMP': + case 'DUE': + case 'AALARM': + case 'DALARM': + case 'RECURRENCE-ID': + case 'X-RECURRENCE-ID': + // types like AALARM may contain additional data after a ; + // ignore these. + $ts = explode(';', $value); + if (isset($params['VALUE']) && $params['VALUE'] == 'DATE') { + $isDate = true; + $this->setAttribute($tag, $this->_parseDateTime($ts[0], $tzid), $params, true, $this->_parseDate($ts[0])); + } else { + $this->setAttribute($tag, $this->_parseDateTime($ts[0], $tzid), $params); + } + break; + + case 'TRIGGER': + if (isset($params['VALUE'])) { + if ($params['VALUE'] == 'DATE-TIME') { + $this->setAttribute($tag, $this->_parseDateTime($value, $tzid), $params); + } else { + $this->setAttribute($tag, $this->_parseDuration($value), $params); + } + } else { + $this->setAttribute($tag, $this->_parseDuration($value), $params); + } + break; + + // Comma or semicolon seperated dates. + case 'EXDATE': + case 'RDATE': + $dates = array(); + preg_match_all('/[;,]([^;,]*)/', ';' . $value, $values); + + foreach ($values[1] as $value) { + if ((isset($params['VALUE']) + && $params['VALUE'] == 'DATE') || (!isset($params['VALUE']) && $isDate)) { + $dates[] = $this->_parseDate($value); + } else { + $dates[] = $this->_parseDateTime($value, $tzid); + } + } + $this->setAttribute($tag, isset($dates[0]) ? $dates[0] : null, $params, true, $dates); + break; + + // Duration fields. + case 'DURATION': + $this->setAttribute($tag, $this->_parseDuration($value), $params); + break; + + // Period of time fields. + case 'FREEBUSY': + $periods = array(); + preg_match_all('/,([^,]*)/', ',' . $value, $values); + foreach ($values[1] as $value) { + $periods[] = $this->_parsePeriod($value); + } + + $this->setAttribute($tag, isset($periods[0]) ? $periods[0] : null, $params, true, $periods); + break; + + // UTC offset fields. + case 'TZOFFSETFROM': + case 'TZOFFSETTO': + $this->setAttribute($tag, $this->_parseUtcOffset($value), $params); + break; + + // Integer fields. + case 'PERCENT-COMPLETE': + case 'PRIORITY': + case 'REPEAT': + case 'SEQUENCE': + $this->setAttribute($tag, intval($value), $params); + break; + + // Geo fields. + case 'GEO': + if ($this->isOldFormat()) { + $floats = explode(',', $value); + $value = array('latitude' => floatval($floats[1]), + 'longitude' => floatval($floats[0])); + } else { + $floats = explode(';', $value); + $value = array('latitude' => floatval($floats[0]), + 'longitude' => floatval($floats[1])); + } + $this->setAttribute($tag, $value, $params); + break; + + // Recursion fields. # add more flexibility + #case 'EXRULE': + #case 'RRULE': + # $this->setAttribute($tag, trim($value), $params); + # break; + + // Binary fields. + case 'PHOTO': + $this->setAttribute($tag, $value, $params); + break; + + // ADR, ORG and N are lists seperated by unescaped semicolons + // with a specific number of slots. + case 'ADR': + case 'N': + case 'ORG': + $value = trim($value); + // As of rfc 2426 2.4.2 semicolon, comma, and colon must + // be escaped (comma is unescaped after splitting below). + $value = str_replace(array('\\n', '\\N', '\\;', '\\:'), + array("\n", "\n", ';', ':'), + $value); + + // Split by unescaped semicolons: + $values = preg_split('/(?setAttribute($tag, trim($value), $params, true, $values); + break; + + // CATEGORIES is a lists seperated by unescaped commas + // with a unspecific number of slots. + case 'CATEGORIES': + $value = trim($value); + // As of rfc 2426 2.4.2 semicolon, comma, and colon must + // be escaped (semicolon is unescaped after splitting below). + $value = str_replace(array('\\n', '\\N', '\\,', '\\:'), + array("\n", "\n", ',', ':'), + $value); + + // Split by unescaped commas: + $values = preg_split('/(?setAttribute($tag, trim($value), $params, true, $values); + break; + + // String fields. + default: + if ($this->isOldFormat()) { + // vCalendar 1.0 and vCard 2.1 only escape semicolons + // and use unescaped semicolons to create lists. + $value = trim($value); + // Split by unescaped semicolons: + $values = preg_split('/(?setAttribute($tag, trim($value), $params, true, $values); + } else { + $value = trim($value); + // As of rfc 2426 2.4.2 semicolon, comma, and colon + // must be escaped (comma is unescaped after splitting + // below). + $value = str_replace(array('\\n', '\\N', '\\;', '\\:', '\\\\'), + array("\n", "\n", ';', ':', '\\'), + $value); + + // Split by unescaped commas. + $values = preg_split('/(?setAttribute($tag, trim($value), $params, true, $values); + } break; - // Date fields. - case 'COMPLETED': - case 'CREATED': - case 'LAST-MODIFIED': - $this->setAttribute($tag, $this->_parseDateTime($value, $tzid), $params); - break; - - case 'BDAY': - case 'X-SYNCJE-ANNIVERSARY': - $this->setAttribute($tag, $value, $params, true, $this->_parseDate($value)); - break; - - case 'DTEND': - case 'DTSTART': - case 'DTSTAMP': - case 'DUE': - case 'AALARM': - case 'DALARM': - case 'RECURRENCE-ID': - case 'X-RECURRENCE-ID': - // types like AALARM may contain additional data after a ; - // ignore these. - $ts = explode(';', $value); - if (isset($params['VALUE']) && $params['VALUE'] == 'DATE') { - $isDate = true; - $this->setAttribute($tag, $this->_parseDateTime($ts[0], $tzid), $params, true, $this->_parseDate($ts[0])); - } else { - $this->setAttribute($tag, $this->_parseDateTime($ts[0], $tzid), $params); - } - break; - - case 'TRIGGER': - if (isset($params['VALUE'])) { - if ($params['VALUE'] == 'DATE-TIME') { - $this->setAttribute($tag, $this->_parseDateTime($value, $tzid), $params); - } else { - $this->setAttribute($tag, $this->_parseDuration($value), $params); - } - } else { - $this->setAttribute($tag, $this->_parseDuration($value), $params); - } - break; - - // Comma or semicolon seperated dates. - case 'EXDATE': - case 'RDATE': - $dates = array(); - preg_match_all('/[;,]([^;,]*)/', ';' . $value, $values); - - foreach ($values[1] as $value) { - if ((isset($params['VALUE']) - && $params['VALUE'] == 'DATE') || (!isset($params['VALUE']) && $isDate)) { - $dates[] = $this->_parseDate($value); - } else { - $dates[] = $this->_parseDateTime($value, $tzid); - } - } - $this->setAttribute($tag, isset($dates[0]) ? $dates[0] : null, $params, true, $dates); - break; - - // Duration fields. - case 'DURATION': - $this->setAttribute($tag, $this->_parseDuration($value), $params); - break; - - // Period of time fields. - case 'FREEBUSY': - $periods = array(); - preg_match_all('/,([^,]*)/', ',' . $value, $values); - foreach ($values[1] as $value) { - $periods[] = $this->_parsePeriod($value); - } - - $this->setAttribute($tag, isset($periods[0]) ? $periods[0] : null, $params, true, $periods); - break; - - // UTC offset fields. - case 'TZOFFSETFROM': - case 'TZOFFSETTO': - $this->setAttribute($tag, $this->_parseUtcOffset($value), $params); - break; - - // Integer fields. - case 'PERCENT-COMPLETE': - case 'PRIORITY': - case 'REPEAT': - case 'SEQUENCE': - $this->setAttribute($tag, intval($value), $params); - break; - - // Geo fields. - case 'GEO': - if ($this->isOldFormat()) { - $floats = explode(',', $value); - $value = array('latitude' => floatval($floats[1]), - 'longitude' => floatval($floats[0])); - } else { - $floats = explode(';', $value); - $value = array('latitude' => floatval($floats[0]), - 'longitude' => floatval($floats[1])); - } - $this->setAttribute($tag, $value, $params); - break; - - // Recursion fields. # add more flexibility - #case 'EXRULE': - #case 'RRULE': - # $this->setAttribute($tag, trim($value), $params); - # break; - - // Binary fields. - case 'PHOTO': - $this->setAttribute($tag, $value, $params); - break; - - // ADR, ORG and N are lists seperated by unescaped semicolons - // with a specific number of slots. - case 'ADR': - case 'N': - case 'ORG': - $value = trim($value); - // As of rfc 2426 2.4.2 semicolon, comma, and colon must - // be escaped (comma is unescaped after splitting below). - $value = str_replace(array('\\n', '\\N', '\\;', '\\:'), - array("\n", "\n", ';', ':'), - $value); - - // Split by unescaped semicolons: - $values = preg_split('/(?setAttribute($tag, trim($value), $params, true, $values); - break; - - // CATEGORIES is a lists seperated by unescaped commas - // with a unspecific number of slots. - case 'CATEGORIES': - $value = trim($value); - // As of rfc 2426 2.4.2 semicolon, comma, and colon must - // be escaped (semicolon is unescaped after splitting below). - $value = str_replace(array('\\n', '\\N', '\\,', '\\:'), - array("\n", "\n", ',', ':'), - $value); - - // Split by unescaped commas: - $values = preg_split('/(?setAttribute($tag, trim($value), $params, true, $values); - break; - - // String fields. - default: - if ($this->isOldFormat()) { - // vCalendar 1.0 and vCard 2.1 only escape semicolons - // and use unescaped semicolons to create lists. - $value = trim($value); - // Split by unescaped semicolons: - $values = preg_split('/(?setAttribute($tag, trim($value), $params, true, $values); - } else { - $value = trim($value); - // As of rfc 2426 2.4.2 semicolon, comma, and colon - // must be escaped (comma is unescaped after splitting - // below). - $value = str_replace(array('\\n', '\\N', '\\;', '\\:', '\\\\'), - array("\n", "\n", ';', ':', '\\'), - $value); - - // Split by unescaped commas. - $values = preg_split('/(?setAttribute($tag, trim($value), $params, true, $values); - } - break; - } + } } } @@ -1128,10 +1128,17 @@ class Horde_iCalendar { } } - if (!empty($params['ENCODING']) && strlen(trim($value))) { + $encoding = (!empty($params['ENCODING']) && strlen(trim($value)) > 0); + + if ($encoding) { switch($params['ENCODING']) { case 'Q': case 'QUOTED-PRINTABLE': + if (!$this->isOldFormat()) + { + $enconding = false; + break; + } $params_str .= ';ENCODING=' . $params['ENCODING']; $value = str_replace("\r", '', $value); $result .= $name . $params_str . ':' @@ -1140,9 +1147,14 @@ class Horde_iCalendar { . $this->_newline; break; case 'FUNAMBOL-QP': - // Funambol does not support wrapping and needs some special quoting - $params_str .= ';ENCODING=QUOTED-PRINTABLE'; + // Funambol needs some special quoting $value = str_replace(array('<', "\r"), array('<', ''), $value); + if (!$this->isOldFormat()) + { + $encoding = false; + break; + } + $params_str .= ';ENCODING=QUOTED-PRINTABLE'; $result .= $name . $params_str . ':' . str_replace('=0A', '=0D=0A', $this->_quotedPrintableEncode($value, false)) @@ -1159,7 +1171,9 @@ class Horde_iCalendar { $result .= $this->_newline; // Append an empty line } } - } else { + } + + if (!$encoding) { $value = str_replace(array("\r", "\n"), array('', '\\n'), $value); $attr_string = $name . $params_str; if (strlen($value) > 0) {