Bug#764915: [DAViCal-devel] Bug#764915: davical: trying to push a event before 1900 results in response 500
On Tue, Dec 16, 2014 at 10:46:59AM +0100, Benedikt Spranger wrote: > > > trying to push a event started befor 1900 results in a database > > > error and therefor in a 500 response to the client. > The underlaying database refuses to accept "18961224" as date while > "19011224" works out pretty well. My "works for me" changes "18961224" > or "19011224" into "18961224T00Z" or "19011224T00Z" which both > are accepted as dates. Reading around a bit, rfc2445 says in 4.6.1 that the VEVENT component is used for anniversaries with a DATE value type for the DTSTART property instead of the default DATE-TIME. So "18961224" is indeed a valid value for DTSTART. The postgres dtstart field is of type TIMESTAMP WITH TIME ZONE, which neither "18961224" nor "19011224" conforms to. I'm unable to deduce from the postgres documentation why the two are processed differently. Now "18961224T00Z" would make for a valid TIMESTAMP WITH TIME ZONE, but I'm not sure this conversion leads to correct results in CalDAV terms: - the DTSTART property generated from it will likely be DATE-TIME instead of just DATE; I wonder if that changes the way clients display the event - I worry that depending on the local timezone offset relative to UTC, clients might display the event on the preceding day, instead of "floating" independent on timezone. Am I worrying too much about things already solved elsewhere in DAViCal? Why is postgres throwing errors, is that a new behaviour, how is "19011224" interpreted w.r.t. the concerns raised above when written to a TIMESTAMP WITH TIME ZONE field? Perhaps other people can chime in here... Florian > > > > A workaround patch is attached. > > Why is it a workaround, what would be the proper solution? > Better: It is a "works for me". It may wash your windows, > mend your fences, mow your lawn... > > > > diff --git a/inc/caldav-PUT-functions.php > > > b/inc/caldav-PUT-functions.php index a1c9e3d..3f1b7d4 100644 > > > --- a/inc/caldav-PUT-functions.php > > > +++ b/inc/caldav-PUT-functions.php > > > @@ -1278,12 +1278,16 @@ function write_resource( DAVResource > > > $resource, $caldav_data, DAVResource $colle if ( $first->GetType() > > > == 'VTODO' ) $due = $first->GetPValue('DUE'); > > > $calitem_params[':due'] = $due; $dtstart = > > > $first->GetPValue('DTSTART'); > > > - if ( empty($dtstart) ) $dtstart = $due; > > > + if ( empty($dtstart) ) $dtstart = $due; > > > + if (preg_match("/^[0-9][0-9][0-9][0-9][01][0-9][0-3][0-9]$/", > > > $dtstart)) > > > + $dtstart = $dtstart . "T00Z"; > > >$calitem_params[':dtstart'] = $dtstart; > > > > > >$dtend = $first->GetPValue('DTEND'); > > >if ( isset($dtend) && $dtend != '' ) { > > > dbg_error_log( 'PUT', ' DTEND: "%s", DTSTART: "%s", DURATION: > > > "%s"', $dtend, $dtstart, $first->GetPValue('DURATION') ); > > > +if (preg_match("/^[0-9][0-9][0-9][0-9][01][0-9][0-3][0-9]$/", > > > $dtend)) > > > + $dtend = $dtend . "T00Z"; > > > $calitem_params[':dtend'] = $dtend; > > > $dtend = ':dtend'; > > >} -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Bug#764915: [DAViCal-devel] Bug#764915: davical: trying to push a event before 1900 results in response 500
On Tue, 16 Dec 2014 08:49:38 +0100 Florian Schlichting wrote: Hi Florian, > > trying to push a event started befor 1900 results in a database > > error and therefor in a 500 response to the client. > could you say a little more about your patch, making it easier for me > to understand why it is effective on those particular dates (and does > it have effects on more current dates?), whether it's a change that > might need to be made in other parts of the code as well? The underlaying database refuses to accept "18961224" as date while "19011224" works out pretty well. My "works for me" changes "18961224" or "19011224" into "18961224T00Z" or "19011224T00Z" which both are accepted as dates. > > A workaround patch is attached. > Why is it a workaround, what would be the proper solution? Better: It is a "works for me". It may wash your windows, mend your fences, mow your lawn... > > diff --git a/inc/caldav-PUT-functions.php > > b/inc/caldav-PUT-functions.php index a1c9e3d..3f1b7d4 100644 > > --- a/inc/caldav-PUT-functions.php > > +++ b/inc/caldav-PUT-functions.php > > @@ -1278,12 +1278,16 @@ function write_resource( DAVResource > > $resource, $caldav_data, DAVResource $colle if ( $first->GetType() > > == 'VTODO' ) $due = $first->GetPValue('DUE'); > > $calitem_params[':due'] = $due; $dtstart = > > $first->GetPValue('DTSTART'); > > - if ( empty($dtstart) ) $dtstart = $due; > > + if ( empty($dtstart) ) $dtstart = $due; > > + if (preg_match("/^[0-9][0-9][0-9][0-9][01][0-9][0-3][0-9]$/", > > $dtstart)) > > + $dtstart = $dtstart . "T00Z"; > >$calitem_params[':dtstart'] = $dtstart; > > > >$dtend = $first->GetPValue('DTEND'); > >if ( isset($dtend) && $dtend != '' ) { > > dbg_error_log( 'PUT', ' DTEND: "%s", DTSTART: "%s", DURATION: > > "%s"', $dtend, $dtstart, $first->GetPValue('DURATION') ); > > +if (preg_match("/^[0-9][0-9][0-9][0-9][01][0-9][0-3][0-9]$/", > > $dtend)) > > + $dtend = $dtend . "T00Z"; > > $calitem_params[':dtend'] = $dtend; > > $dtend = ':dtend'; > >} -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Bug#764915: [DAViCal-devel] Bug#764915: davical: trying to push a event before 1900 results in response 500
Hi Benedikt, > trying to push a event started befor 1900 results in a database error > and therefor in a 500 response to the client. could you say a little more about your patch, making it easier for me to understand why it is effective on those particular dates (and does it have effects on more current dates?), whether it's a change that might need to be made in other parts of the code as well? > A workaround patch is attached. Why is it a workaround, what would be the proper solution? > diff --git a/inc/caldav-PUT-functions.php b/inc/caldav-PUT-functions.php > index a1c9e3d..3f1b7d4 100644 > --- a/inc/caldav-PUT-functions.php > +++ b/inc/caldav-PUT-functions.php > @@ -1278,12 +1278,16 @@ function write_resource( DAVResource $resource, > $caldav_data, DAVResource $colle >if ( $first->GetType() == 'VTODO' ) $due = $first->GetPValue('DUE'); >$calitem_params[':due'] = $due; >$dtstart = $first->GetPValue('DTSTART'); > - if ( empty($dtstart) ) $dtstart = $due; > + if ( empty($dtstart) ) $dtstart = $due; > + if (preg_match("/^[0-9][0-9][0-9][0-9][01][0-9][0-3][0-9]$/", $dtstart)) > + $dtstart = $dtstart . "T00Z"; >$calitem_params[':dtstart'] = $dtstart; > >$dtend = $first->GetPValue('DTEND'); >if ( isset($dtend) && $dtend != '' ) { > dbg_error_log( 'PUT', ' DTEND: "%s", DTSTART: "%s", DURATION: "%s"', > $dtend, $dtstart, $first->GetPValue('DURATION') ); > +if (preg_match("/^[0-9][0-9][0-9][0-9][01][0-9][0-3][0-9]$/", $dtend)) > + $dtend = $dtend . "T00Z"; > $calitem_params[':dtend'] = $dtend; > $dtend = ':dtend'; >} Florian -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org