[Kolab-devel] iCalender.php patches in kolab-horde-framework (was: Kolab-resource-handlers dependency on Horde libraries)
Gunnar Wrobel
wrobel at pardus.de
Wed Nov 22 10:51:10 CET 2006
Gunnar Wrobel <wrobel at gentoo.org> writes:
> Leaves the iCalendar patch but I'll tackle that later when I have more time.
A while ago I posted the analysis script to extract the patches that
were applied to kolab-horde-framework after the fork from the original
horde cvs (script available at http://wiki.kolab.org/index.php/Horde).
The result were two patches in the iCalendar module of the horde
framework. One to framework/iCalendar/iCalendar/vfreebusy.php (will be
sent upstream to horde soon) and one to
framework/iCalendar/iCalendar.php. I did analyse the code changes of
the second patch now. This analysis should be pretty irrelevant to
most kolab users and even devs but I believe it is useful to have it
as a reference.
The summary:
The modifications to iCalender.php found in the kolab fork have nearly
all been covered by fixes in horde CVS and should not be necessary
anymore. There is only one change that might still be relevant.
The details:
The following patch results from running the analysis script mentioned
above. I'll go through the patch sections and comment the different
parts. The only section where I believe it might be a necessary patch
for Kolab is the very last section.
Index: iCalendar/iCalendar.php
===================================================================
RCS file: /home/kroupware/jail/kolabrepository/server/kolab-resource-handlers/kolab-resource-handlers/fbview/fbview/framework/iCalendar/Attic/iCalendar.php,v
retrieving revision 1.1
retrieving revision 1.7
diff -u -B -r1.1 -r1.7
--- iCalendar/iCalendar.php 11 Jun 2004 10:51:24 -0000 1.1
+++ iCalendar/iCalendar.php 29 Aug 2005 23:52:34 -0000 1.7
@@ -10,7 +10,7 @@
* did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
*
* @author Mike Cochrane <mike at graftonhall.co.nz>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.7 $
* @since Horde 3.0
* @package Horde_iCalendar
*/
Comment:
Irrelevant.
@@ -288,12 +289,23 @@
// Unfold any folded lines.
$vCal = preg_replace ('/(\r|\n)+ /', '', $vCal);
+ // Unfold "quoted printable" folded lines like:
+ // BODY;ENCODING=QUOTED-PRINTABLE:=
+ // another=20line=
+ // last=20line
+ if (preg_match_all('/^([^:]+;\s*ENCODING=QUOTED-PRINTABLE(.*=\r?\n)+(.*[^=])?\r?\n)/mU', $vCal, $matches)) {
+ foreach ($matches[1] as $s) {
+ $r = preg_replace('/=\r?\n/', '', $s);
+ $vCal = str_replace($s, $r, $vCal);
+ }
+ }
+
Comment:
Code section present in iCalendar.php of current horde CVS
// Parse the remaining attributes.
- if (preg_match_all('/(.*):(.*)(\r|\n)+/', $vCal, $matches)) {
+ if (preg_match_all('/(.*):([^\r\n]*)[\r\n]+/', $vCal, $matches)) {
foreach ($matches[0] as $attribute) {
- preg_match('/([^;^:]*)((;[^:]*)?):(.*)/', $attribute, $parts);
+ preg_match('/([^;^:]*)((;.*)?|(;[^:;=]+=(".*"|[^:;=]*))+):([^\r\n]*)[\r\n]*/', $attribute, $parts);
$tag = $parts[1];
- $value = $parts[4];
+ $value = $parts[6];
$params = array();
if (!empty($parts[2])) {
Comment:
Regex expression in horde cvs has been fixed but is slightly simpler
than the one in kolab-horde-frameworks. I did not find a reason why
the current horde version should not work.
@@ -306,8 +318,13 @@
switch ($tag) {
case 'DESCRIPTION':
+ case 'SUMMARY':
+ case 'LOCATION':
$value = preg_replace('/\\\\,/', ',', $value);
+ $value = preg_replace('/\\\\;/', ';', $value);
$value = preg_replace('/\\\\n/', $this->_newline, $value);
+ $value = preg_replace('/\\\\N/', $this->_newline, $value);
+ $value = preg_replace('/\\\\\\\\/', '\\\\', $value);
$this->setAttribute($tag, $value, $params);
break;
Comment:
These keywords (DESCRIPTION, SUMMARY, LOCATION) are handled by
standard string mangling in horde cvs now (case default). The code
lines here do not provide any additional functionality beside
performing the standard iCalendar escaping.
@@ -360,9 +377,8 @@
case 'EXDATE':
$values = array();
$dates = array();
- preg_match_all('/,([^,]*)/', ',' . $value, $values);
-
- foreach ($values as $value) {
+ preg_match_all('/,([^,]*)/', ',' . $value, $values, PREG_PATTERN_ORDER );
+ foreach ($values[1] as $value) {
if (isset($params['VALUE'])) {
if ($params['VALUE'] == 'DATE-TIME') {
$dates[] = $this->_parseDateTime($value);
Comment:
PREG_PATTERN_ORDER is an unnecessary flag here since it is the php
default for this function.
foreach ($values[1] as $value) has been also fixed in horde cvs.
@@ -541,6 +557,10 @@
case 'EXRULE':
case 'RRULE':
}
+ $value = preg_replace('/\\\\/', '\\\\\\\\', $value);
+ $value = preg_replace('/,/', '\\,', $value);
+ $value = preg_replace('/;/', '\\;', $value);
+ $value = preg_replace('/'.$this->_newline.'/', '\\n', $value);
$attr_string = "$name$params_str:$value";
$result .= $this->_foldLine($attr_string) . $this->_newline;
Comment:
This is part of the data export section of the code. The old code in
horde cvs apparently did not get the escaping right but I believe the
current version does. There are code sections in horde cvs that are
more complex than what can be found in kolab-horde-framework and it
covers the different iCalendar formats.
@@ -657,17 +677,19 @@
{
$temp = array();
if (!is_object($value) || is_array($value)) {
- $TZOffset = 3600 * substr(date('O'), 0, 3);
- $TZOffset += 60 * substr(date('O'), 3, 2);
+ // NOTE(steffen): We store time in UTC only(!)
+ /*
+ $TZOffset = 3600 * substr(date('O',$value), 0, 3);
+ $TZOffset += 60 * substr(date('O',$value), 3, 2);
$value -= $TZOffset;
-
+ */
$temp['zone'] = 'UTC';
- $temp['year'] = date('Y', $value);
- $temp['month'] = date('n', $value);
- $temp['mday'] = date('j', $value);
- $temp['hour'] = date('G', $value);
- $temp['minute'] = date('i', $value);
- $temp['second'] = date('s', $value);
+ $temp['year'] = gmdate('Y', $value);
+ $temp['month'] = gmdate('n', $value);
+ $temp['mday'] = gmdate('j', $value);
+ $temp['hour'] = gmdate('G', $value);
+ $temp['minute'] = gmdate('i', $value);
+ $temp['second'] = gmdate('s', $value);
} else {
$dateOb = (object)$value;
Comment:
Here I am uncertain of the meaning of this modification. It was
intruduced here:
http://kolab.org/cgi-bin/viewcvs-kolab.cgi/server/kolab-resource-handlers/kolab-resource-handlers/fbview/fbview/framework/iCalendar/Attic/iCalendar.php.diff?r1=1.2&r2=1.3&hideattic=0
and refers to bug
https://intevation.de/roundup/kolab/issue486
While the patch probably makes things work the attached note suggests
that it limits the iCalendar library in horde to a single use case
(UTC times). I am not quite certain that this patch would make it into
upstream horde cvs. It might be better to try to fix the issue
somewhere within the resmgr or freebusy scripts.
I did not dive deep enough into the code to understand the reasons
behind the change so I wanted to ask whether somebody - probably
Steffen ;) - could enlighten me there.
So much for the iCalendar.php script.
Cheers,
Gunnar
--
____ http://www.pardus.de _________________ http://gunnarwrobel.de _
E-mail : wrobel at pardus.de Dr. Gunnar Wrobel
Tel. : +49 40 432 72335 Hartwig-Hesse Str. 12
Fax : +49 40 432 70855 D-20257 Hamburg
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> Mail at ease - Kolab out of the box << P at rdus
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
More information about the devel
mailing list