[CalendarServer-changes] [5288] CalendarServer/trunk/twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Thu Mar 11 16:48:13 PST 2010
Revision: 5288
http://trac.macosforge.org/projects/calendarserver/changeset/5288
Author: sagen at apple.com
Date: 2010-03-11 16:48:12 -0800 (Thu, 11 Mar 2010)
Log Message:
-----------
Don't allow a mismatch on the value type between DTSTART and RRULE UNTIL.
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/ical.py
CalendarServer/trunk/twistedcaldav/test/test_icalendar.py
Modified: CalendarServer/trunk/twistedcaldav/ical.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/ical.py 2010-03-12 00:44:30 UTC (rev 5287)
+++ CalendarServer/trunk/twistedcaldav/ical.py 2010-03-12 00:48:12 UTC (rev 5288)
@@ -1320,6 +1320,23 @@
else:
component_rids.add(rid)
+ # Check for mismatch in DTSTART and UNTIL value type
+ # If they're not both date or both date-time, raise error
+ if (subcomponent.hasProperty("DTSTART") and
+ subcomponent.hasProperty("RRULE")):
+ dtType = type(subcomponent.getProperty("DTSTART").value())
+ for rrule in subcomponent.properties("RRULE"):
+ indexedTokens = {}
+ indexedTokens.update([valuePart.split("=")
+ for valuePart in rrule.value().split(";")])
+ until = indexedTokens.get('UNTIL', None)
+ if until:
+ untilType = datetime.date if len(until) == 8 else datetime.datetime
+ if untilType is not dtType:
+ msg = "Calendar resources must have matching type for DTSTART and UNTIL"
+ log.debug(msg)
+ raise InvalidICalendarDataError(msg)
+
timezone_refs.update(subcomponent.timezoneIDs())
#
Modified: CalendarServer/trunk/twistedcaldav/test/test_icalendar.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_icalendar.py 2010-03-12 00:44:30 UTC (rev 5287)
+++ CalendarServer/trunk/twistedcaldav/test/test_icalendar.py 2010-03-12 00:48:12 UTC (rev 5288)
@@ -23,7 +23,7 @@
from twisted.trial.unittest import SkipTest
from twistedcaldav.ical import Component, parse_date, parse_datetime,\
- parse_date_or_datetime, parse_duration, Property
+ parse_date_or_datetime, parse_duration, Property, InvalidICalendarDataError
from twistedcaldav.instance import InvalidOverriddenInstanceError
import twistedcaldav.test.util
@@ -3123,3 +3123,100 @@
self.assertEqual(str(ical1), str(ical2), "Failed comparison: %s\n%s" % (title, diff,))
elif changed:
self.fail("Truncation happened when not expected: %s" % (title,))
+
+ def test_mismatched_until(self):
+ invalid = (
+ """BEGIN:VCALENDAR
+VERSION:2.0
+CALSCALE:GREGORIAN
+PRODID:-//Apple Inc.//iCal 3.0//EN
+BEGIN:VTIMEZONE
+TZID:US/Pacific
+BEGIN:STANDARD
+DTSTART:20071104T020000
+RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
+TZNAME:PST
+TZOFFSETFROM:-0700
+TZOFFSETTO:-0800
+END:STANDARD
+BEGIN:DAYLIGHT
+DTSTART:20070311T020000
+RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
+TZNAME:PDT
+TZOFFSETFROM:-0800
+TZOFFSETTO:-0700
+END:DAYLIGHT
+END:VTIMEZONE
+BEGIN:VEVENT
+UID:FB81D520-ED27-4DBA-8894-45B7612A7621
+DTSTART;TZID=US/Pacific:20090705T100000
+DTEND;TZID=US/Pacific:20090730T103000
+CREATED:20090604T225706Z
+DTSTAMP:20090604T230500Z
+RRULE:FREQ=DAILY;INTERVAL=1;UNTIL=20090706
+SEQUENCE:1
+SUMMARY:TEST
+TRANSP:OPAQUE
+END:VEVENT
+BEGIN:VEVENT
+UID:FB81D520-ED27-4DBA-8894-45B7612A7621
+RECURRENCE-ID;TZID=US/Pacific:20090705T100000
+DTSTART;TZID=US/Pacific:20090705T114500
+DTEND;TZID=US/Pacific:20090705T121500
+CREATED:20090604T225706Z
+DTSTAMP:20090604T230504Z
+SEQUENCE:2
+SUMMARY:TEST
+TRANSP:OPAQUE
+END:VEVENT
+END:VCALENDAR
+""",
+ """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//Apple Inc.//iCal 4.0.2//EN
+CALSCALE:GREGORIAN
+BEGIN:VEVENT
+CREATED:20100311T234221Z
+UID:D0151FAD-4739-4B61-96EB-9289FF1F7716
+DTEND;VALUE=DATE:20100316
+RRULE:FREQ=WEEKLY;INTERVAL=1;UNTIL=20110604T225706Z
+TRANSP:TRANSPARENT
+SUMMARY:ALL DAY
+DTSTART;VALUE=DATE:20100315
+DTSTAMP:20100312T002640Z
+SEQUENCE:5
+END:VEVENT
+END:VCALENDAR
+""",
+ )
+
+ valid = (
+ """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//Apple Inc.//iCal 4.0.2//EN
+CALSCALE:GREGORIAN
+BEGIN:VEVENT
+CREATED:20100311T234221Z
+UID:D0151FAD-4739-4B61-96EB-9289FF1F7716
+DTEND;VALUE=DATE:20100316
+RRULE:FREQ=WEEKLY;INTERVAL=1;UNTIL=20110316
+TRANSP:TRANSPARENT
+SUMMARY:ALL DAY
+DTSTART;VALUE=DATE:20100315
+DTSTAMP:20100312T002640Z
+SEQUENCE:5
+END:VEVENT
+END:VCALENDAR
+""",
+ )
+
+
+ for text in invalid:
+ calendar = Component.fromString(text)
+ self.assertRaises(InvalidICalendarDataError, calendar.validateForCalDAV)
+ for text in valid:
+ calendar = Component.fromString(text)
+ try:
+ calendar.validateForCalDAV()
+ except:
+ self.fail("Valid calendar should validate")
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100311/87d55b91/attachment.html>
More information about the calendarserver-changes
mailing list