[Freeassociation-devel] One simple event causing crash of the application
crass at berlios.de
crass at berlios.de
Fri Mar 26 10:44:54 PDT 2010
Milan,
First, thanks for submitting the test code that's exactly what was
needed to figure things out. I've tested your code with the latest SVN
and I am getting "got '00000000T000000' expected '20070122T000000Z'" as
output, which I assume is what you're getting.
This might actually be considered a programming error in the project
using the test code. It would be nice for libical to know exactly
which types of values a certain property can have (in this case DTSTART
can have DATE or DATE-TIME). But there's no such knowledge of that in
libical at this moment.
Right now the ical parser assumes that if you give a VALUE= type that
it does not know about, that the value is an X-Value. It does know
about the type X though, which is the X-Value type. So you would get
the same result for VALUE=CHEESE.
What you are ending up with is a DTSTART property with a value of type
X-VALUE, but icalcomponent_get_dtstart assumes its a time type, which
its not. In fact, icalcomponent_get_dtstart calls
icalvalue_get_datetime, which in turn calls which does the conversion.
There is a "icalerror_check_value_type" check in
icalvalue_get_datetime, but unfortunately icalerror_check_*_type macros
are defined to do nothing right now.
So you'll have to manually
perform this check for now.
To check that DTSTART is the right value type you can probably do
something like:
icalproperty *dtprop =
icalcomponent_get_first_property(icalcomponent_get_inner(comp),
ICAL_DTSTART_PROPERTY)
if (dtprop && (icalproperty_isa(dtprop, ICAL_DATE_VALUE) ||
icalproperty_isa(dtprop, ICAL_DATETIME_VALUE))) {
/* we got a valid date */
struct icaltimetype itt = icalcomponent_get_dtstart(comp);
/* more processing of event */
} else {
/* skip this event */
}
Of course, you'd have to check for each datetime field (DTEND, etc..).
I'm not sure how we want to fix this in libical right now. I'm
considering for the time being defining icalerror_check_*_type to set
the icalerrno to ICAL_USAGE_ERROR, so at least you can know that some
kind of error happened and that something suspicious is a foot.
Anyone else have any ideas on this?
Glenn
On Fri, 26 Mar 2010 14:28:26 +0100
Milan Crha <mcrha at redhat.com> wrote:
> Hi,
> OK, I have libical-0.43-5.fc12 (I guess it's getting this one, not the
> latest svn I just compiled). Anyway, the attached test.c is what you
> are looking for.
>
> What I expect from it is that it'll return me a date which is set in
> DTSTART when I call icalcomponent_get_dtstart, but it returns null
> time, so Evolution generates recurrences from the beginning of the
> epoch, not the time which has the DTSTART set. Changing DTSTART's
> VALUE to DATE or DATE-TIME from its current "X", or even removing it
> completely makes it behave properly.
>
> Please not that I agree the VALUE=X cannot be there, as is mentioned
> in the RFC I gave a link to in the bug report, but I'm asking for
> some fix on a libical side to behave sanely on such kind of an error.
> Either add there a parse error or something like that in this case,
> or be more forgiving, rather than "pretending" the value is correct,
> even it isn't.
>
> Thanks and bye,
> Milan
More information about the libical-devel
mailing list