From fabacecd16eb62ff94dfa8955862852a410e3524 Mon Sep 17 00:00:00 2001 From: Lars Henriksen Date: Sat, 2 May 2020 22:14:45 +0200 Subject: Take value data type of event start into account in iCal import/export The patch derives the item type (appointment or event) from the DTSTART value type. It is then used to perform an extended check of date/time values and reject non-conformant import files (like those reported in Github issues #81, (calcurse) events. The patch includes parsing and code corrections and minor refactoring. Background: Ical events are of two types, in calcurse called appointments and events. RFC 5545 has no distinguishing names for them, but describes them in section 3.6.1. The event type is derived from the value type of the DTSTART property. The value type may be either DATE-TIME (appointment) or DATE (event). If not specified by a VALUE property parameter in DTSTART, the default value type is DATE-TIME. The value type must be set explicitly to DATE to get an event. Other properties and rrule parts must agree with the DTSTART value type (DTEND, DURATION, EXDATE and UNTIL). Previously the type of an imported event was derived from the format of the DTSTART value. The DTSTART value type was not taken into account when importing, and not specified for recurring events when exporting (commit 0114289 solved it for events, see GitHub PR #97). Signed-off-by: Lukas Fleischer --- test/data/ical-009.ical | 35 +++++++++++++++++++++++++++++++++++ test/ical-009.sh | 14 ++++++++++---- 2 files changed, 45 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/data/ical-009.ical b/test/data/ical-009.ical index 39ae422..1828417 100644 --- a/test/data/ical-009.ical +++ b/test/data/ical-009.ical @@ -76,6 +76,41 @@ SUMMARY:LOCATION twice LOCATION:first LOCATION:second END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20200406 +DURATION:PT0H15M0S +SUMMARY:Invalid duration (must be days or weeks) +END:VEVENT +BEGIN:VEVENT +DTSTART:20200406 +DURATION:P1D +SUMMARY:Invalid DTSTART value type +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20200406 +SUMMARY:Invalid DTEND value type +DTEND:20200407 +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20200406 +DURATION:P1D +RRULE:FREQ=MONTHLY;UNTIL=20201030T120000Z +SUMMARY:Invalid UNTIL value +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20200406 +DURATION:P1D +RRULE:FREQ=MONTHLY;UNTIL=20201030 +EXDATE:20200606 +SUMMARY:Invalid EXDATE value type +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20200406 +DURATION:P1D +RRULE:FREQ=MONTHLY;UNTIL=20201030 +EXDATE;VALUE=DATE:20200606T120000Z +SUMMARY:Invalid EXDATE value +END:VEVENT BEGIN:VTODO SUMMARY:finally\, missing end of item END:VCALENDAR diff --git a/test/ical-009.sh b/test/ical-009.sh index d912f5c..c8c1c9c 100755 --- a/test/ical-009.sh +++ b/test/ical-009.sh @@ -17,9 +17,9 @@ if [ "$1" = 'actual' ]; then rm -rf .calcurse || exit 1 elif [ "$1" = 'expected' ]; then cat <