Bug 189711 - libkcal stores illegal negative DTSTART in ics / ical files
Summary: libkcal stores illegal negative DTSTART in ics / ical files
Status: RESOLVED FIXED
Alias: None
Product: korganizer
Classification: Applications
Component: general (show other bugs)
Version: 4.2.0
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-04-15 13:56 UTC by Stephan Diestelhorst
Modified: 2009-04-16 01:30 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stephan Diestelhorst 2009-04-15 13:56:19 UTC
Version:            (using KDE 4.2.0)
Compiler:          gcc 4.3.2 (Ubuntu 4.3.2-1ubuntu12) 
OS:                Linux
Installed from:    Ubuntu Packages

Inspecting my std.ics file manually (with external iCalendar lib for python) revealed a buggy VTODO component, containing a negative value for the start date of the todo.

BEGIN:VTODO
DTSTAMP:20090409T091133Z
ORGANIZER;CN="XYZ":MAILTO:xyz@xyz.com
COMMENT:NoStartDate
CREATED:20080707T163805Z
UID:libkcal-1929220871.337
SEQUENCE:3
LAST-MODIFIED:20080721T135652Z
SUMMARY:xyz
PRIORITY:5
RELATED-TO:libkcal-228060668.313
RRULE:FREQ=WEEKLY;BYDAY=FR
EXDATE;VALUE=DATE:20080721
DUE;VALUE=DATE:20080708
DTSTART;VALUE=DATE:-4713010
PERCENT-COMPLETE:0
RECURRENCE-ID:20080707T220000Z
END:VTODO

As per RFC 2445 4.6.2 the dtstart entry for
Comment 1 Sergio Martins 2009-04-15 13:59:49 UTC
Can you reproduce the bug? Any steps we should follow?

Thanks
Comment 2 Stephan Diestelhorst 2009-04-15 14:07:41 UTC
...whoops... accidential send pressed...

As per RFC 2445 4.6.2 the dtstart entry for todoc is optional and according to 4.8.2.4 and 4.3.4 has to be in YYYYMMDD encoding.

The comment suggests that the DTSTART field should be ignored anyway.
The following patch fixes this for my by dropping the bogus and optional DTSTART field if not used.

diff -r afa0e6dcdc6a kcal/icalformat_p.cpp
--- a/kcal/icalformat_p.cpp     Wed Apr 15 14:06:13 2009 +0200
+++ b/kcal/icalformat_p.cpp     Wed Apr 15 14:06:25 2009 +0200
@@ -200,7 +200,7 @@
   }

   // start time
-  if ( todo->hasStartDate() || todo->recurs() ) {
+  if ( todo->hasStartDate() ) {
     icaltimetype start;
     if ( todo->allDay() ) {
       start = writeICalDate( todo->dtStart( true ).date() );

Please apply upstream!
Comment 3 Stephan Diestelhorst 2009-04-15 14:36:07 UTC
Yes, it is easy to reproduce (maybe non-precise translation, I'll do my best):

I've used Kontact, Calendar View, Create new To-Do item (Ctrl + Shift +T)
and created a new Todo-item with the following properties:

(Any title)
Due date tomorrow
Recurrence tab
  Check entry repeats
  Once every week on Thursday

Close Kontact and check std.ics. Result:

BEGIN:VTODO
DTSTAMP:20090415T122651Z
ORGANIZER;CN="Stephan Diestelhorst":MAILTO:stephan.diestelhorst@amd.com
CREATED:20090415T122650Z
UID:libkcal-47342057.563
LAST-MODIFIED:20090415T122650Z
SUMMARY:Check Korganizer
PRIORITY:5
RRULE:FREQ=WEEKLY;BYDAY=TH
DUE;VALUE=DATE:20090416
DTSTART;VALUE=DATE:-47130101
PERCENT-COMPLETE:0
RECURRENCE-ID:20090416T000000
BEGIN:VALARM
DESCRIPTION:
ACTION:DISPLAY
TRIGGER;VALUE=DURATION:-PT15M
END:VALARM

END:VTODO

After applying my patch this results in 
BEGIN:VTODO
DTSTAMP:20090415T123438Z
ORGANIZER;CN="Stephan Diestelhorst":MAILTO:stephan.diestelhorst@amd.com
CREATED:20090415T122650Z
UID:libkcal-47342057.563
LAST-MODIFIED:20090415T122650Z
SUMMARY:Check Korganizer
PRIORITY:5
RRULE:FREQ=WEEKLY;BYDAY=TH
DUE;VALUE=DATE:20090416
PERCENT-COMPLETE:0
RECURRENCE-ID:20090416T000000
BEGIN:VALARM
DESCRIPTION:
ACTION:DISPLAY
TRIGGER;VALUE=DURATION:-PT15M
END:VALARM

END:VTODO

I.e. without the useless DTSTART entry.

HTH
Comment 4 Martin 2009-04-15 15:51:27 UTC
I can confirm this problem.
Comment 5 Sergio Martins 2009-04-16 00:50:18 UTC
This commit might be relevant:
http://websvn.kde.org/?view=rev&revision=330243

quoting:

"""
Some changes in the implementation of recurring todo's. The problem
until now was that the startdate wasn't stored in the calendar. This
caused (sometimes funny) side-affects. In the worst case, KOrganizer
would lock up and all changes were lost. This is fixed now. I think the
feature is ready for release. I'd appreciate any feedback.

Note to all people using post 3.2-calendars AND recurring todo's: This
patch breaks all recurring todo's. Delete all these todo's and recreate
them, to make sure all dates are correctly set.
People with calendars from 3.2 (or earlier) won't be affected.
"""
Comment 6 Allen Winter 2009-04-16 01:30:00 UTC
SVN commit 954583 by winterz:

Fix "libkcal stores illegal negative DTSTART in ics / ical files".
Thanks for figuring out how to fix this Stephan.

BUG: 189711


 M  +1 -1      icalformat_p.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=954583