[CalendarServer-changes] [14139] CalendarServer/trunk/txdav/caldav/datastore/scheduling
source_changes at macosforge.org
source_changes at macosforge.org
Thu Nov 6 13:51:03 PST 2014
Revision: 14139
http://trac.calendarserver.org//changeset/14139
Author: cdaboo at apple.com
Date: 2014-11-06 13:51:03 -0800 (Thu, 06 Nov 2014)
Log Message:
-----------
Fix for leakage of organizer properties into attendee overrides.
Modified Paths:
--------------
CalendarServer/trunk/txdav/caldav/datastore/scheduling/itip.py
CalendarServer/trunk/txdav/caldav/datastore/scheduling/test/test_itip.py
Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/itip.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/itip.py 2014-11-06 21:49:07 UTC (rev 14138)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/itip.py 2014-11-06 21:51:03 UTC (rev 14139)
@@ -127,9 +127,9 @@
current_master = calendar.masterComponent()
if current_master:
valarms = [comp for comp in current_master.subcomponents() if comp.name() == "VALARM"]
- private_comments = current_master.properties("X-CALENDARSERVER-PRIVATE-COMMENT")
- transps = current_master.properties("TRANSP")
- completeds = current_master.properties("COMPLETED")
+ private_comments = tuple(current_master.properties("X-CALENDARSERVER-PRIVATE-COMMENT"))
+ transps = tuple(current_master.properties("TRANSP"))
+ completeds = tuple(current_master.properties("COMPLETED"))
organizer = current_master.getProperty("ORGANIZER")
organizer_schedule_status = organizer.parameterValue("SCHEDULE-STATUS", None) if organizer else None
attendee = current_master.getAttendeeProperty((recipient,))
@@ -137,8 +137,7 @@
other_props = {}
for pname in config.Scheduling.CalDAV.PerAttendeeProperties:
props = tuple(current_master.properties(pname))
- if props:
- other_props[pname] = props
+ other_props[pname] = props
else:
valarms = ()
private_comments = ()
@@ -605,9 +604,9 @@
matched = from_calendar.overriddenComponent(rid)
if matched:
valarms = [comp for comp in matched.subcomponents() if comp.name() == "VALARM"]
- private_comments = matched.properties("X-CALENDARSERVER-PRIVATE-COMMENT")
- transps = matched.properties("TRANSP")
- completeds = matched.properties("COMPLETED")
+ private_comments = tuple(matched.properties("X-CALENDARSERVER-PRIVATE-COMMENT"))
+ transps = tuple(matched.properties("TRANSP"))
+ completeds = tuple(matched.properties("COMPLETED"))
organizer = matched.getProperty("ORGANIZER")
organizer_schedule_status = organizer.parameterValue("SCHEDULE-STATUS", None) if organizer else None
attendee = matched.getAttendeeProperty((recipient,))
@@ -615,8 +614,7 @@
other_props = {}
for pname in config.Scheduling.CalDAV.PerAttendeeProperties:
props = tuple(matched.properties(pname))
- if props:
- other_props[pname] = props
+ other_props[pname] = props
seq_change = Component.compareComponentsForITIP(to_component, matched, use_dtstamp=False) <= 0
iTipProcessing._transferItems(to_component, transfer_partstat and seq_change, valarms, private_comments, transps, completeds, organizer_schedule_status, attendee, attendee_dtstamp, other_props, recipient)
@@ -638,15 +636,15 @@
to_attendee.setParameter("PARTSTAT", attendee.parameterValue("PARTSTAT", "NEEDS-ACTION"))
else:
+ master_component = from_calendar.masterComponent()
+ seq_change = (Component.compareComponentsForITIP(to_component, master_component, use_dtstamp=False) <= 0) if master_component is not None else True
+ iTipProcessing._transferItems(to_component, transfer_partstat and seq_change, valarms, private_comments, transps, completeds, organizer_schedule_status, attendee, attendee_dtstamp, other_props, recipient)
+
# Check for incoming DECLINED
attendee = to_component.getAttendeeProperty((recipient,))
if attendee and attendee.parameterValue("PARTSTAT", "NEEDS-ACTION") == "DECLINED":
return True
- master_component = from_calendar.masterComponent()
- seq_change = (Component.compareComponentsForITIP(to_component, master_component, use_dtstamp=False) <= 0) if master_component is not None else True
- iTipProcessing._transferItems(to_component, transfer_partstat and seq_change, valarms, private_comments, transps, completeds, organizer_schedule_status, attendee, attendee_dtstamp, other_props, recipient)
-
return False
@@ -681,11 +679,21 @@
"""
# It is a new override - copy any valarms on the existing master component
- # into the new one.
+ # into the new one. But first remove any of the stuff we want to copy from
+ # the component being copied to.
+ to_component.removeAlarms()
+ to_component.removeProperty("X-CALENDARSERVER-PRIVATE-COMMENT")
+ to_component.removeProperty("TRANSP")
+ to_component.removeProperty("COMPLETED")
+ for propname in other_props.keys():
+ to_component.removeProperty(propname)
+
[to_component.addComponent(alarm) for alarm in valarms]
[to_component.addProperty(comment) for comment in private_comments]
[to_component.replaceProperty(transp) for transp in transps]
[to_component.replaceProperty(completed) for completed in completeds]
+ for props in other_props.values():
+ [to_component.replaceProperty(prop) for prop in props]
if organizer_schedule_status:
organizer = to_component.getProperty("ORGANIZER")
@@ -700,9 +708,6 @@
if attendee_dtstamp and attendee:
attendee.setParameter("X-CALENDARSERVER-DTSTAMP", attendee_dtstamp)
- for props in other_props.values():
- [to_component.replaceProperty(prop) for prop in props]
-
return False
Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/test/test_itip.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/test/test_itip.py 2014-11-06 21:49:07 UTC (rev 14138)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/test/test_itip.py 2014-11-06 21:51:03 UTC (rev 14139)
@@ -758,6 +758,291 @@
self.assertEqual(result, changed, msg="Calendar mismatch: %s" % (title,))
+ def test_processRequest_propertyLeakage(self):
+ """
+ Test iTIPProcessing.processRequest properly ignores properties from organizer that need to be overridden by
+ the attendee
+ """
+
+ data = (
+ (
+ "1.1 All ACCEPTED, no alarm",
+ """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-1
+DTSTART:20071114T000000Z
+DURATION:PT1H
+DTSTAMP:20071114T000000Z
+ATTENDEE:mailto:user01 at example.com
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user02 at example.com
+ORGANIZER:mailto:user01 at example.com
+RRULE:FREQ=DAILY
+SUMMARY:Test
+TRANSP:TRANSPARENT
+X-APPLE-TRAVEL-DURATION;VALUE=DURATION:PT30M
+END:VEVENT
+END:VCALENDAR
+""",
+ """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+METHOD:REQUEST
+BEGIN:VEVENT
+UID:12345-67890-1
+DTSTART:20071114T000000Z
+DURATION:PT1H
+DTSTAMP:20071114T000000Z
+ATTENDEE:mailto:user01 at example.com
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user02 at example.com
+ORGANIZER:mailto:user01 at example.com
+RRULE:FREQ=DAILY
+SUMMARY:Test
+TRANSP:OPAQUE
+X-CALENDARSERVER-PRIVATE-COMMENT:foobar1
+X-APPLE-TRAVEL-DURATION;VALUE=DURATION:PT1H
+X-APPLE-TRAVEL-RETURN-DURATION;VALUE=DURATION:PT1H
+BEGIN:VALARM
+DESCRIPTION:Event reminder
+TRIGGER:-PT1M
+ACTION:DISPLAY
+END:VALARM
+END:VEVENT
+BEGIN:VEVENT
+UID:12345-67890-1
+RECURRENCE-ID:20071115T000000Z
+DTSTART:20071115T000000Z
+DURATION:PT1H
+DTSTAMP:20071114T000000Z
+ATTENDEE:mailto:user01 at example.com
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user02 at example.com
+ORGANIZER:mailto:user01 at example.com
+SUMMARY:Test1
+TRANSP:OPAQUE
+X-CALENDARSERVER-PRIVATE-COMMENT:foobar2
+X-APPLE-TRAVEL-DURATION;VALUE=DURATION:PT2H
+X-APPLE-TRAVEL-RETURN-DURATION;VALUE=DURATION:PT2H
+BEGIN:VALARM
+DESCRIPTION:Event reminder
+TRIGGER:-PT2M
+ACTION:DISPLAY
+END:VALARM
+END:VEVENT
+BEGIN:VEVENT
+UID:12345-67890-1
+RECURRENCE-ID:20071116T000000Z
+DTSTART:20071116T000000Z
+DURATION:PT1H
+DTSTAMP:20071114T000000Z
+ATTENDEE:mailto:user01 at example.com
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user02 at example.com
+ORGANIZER:mailto:user01 at example.com
+SUMMARY:Test1
+TRANSP:OPAQUE
+X-CALENDARSERVER-PRIVATE-COMMENT:foobar3
+X-APPLE-TRAVEL-DURATION;VALUE=DURATION:PT3H
+X-APPLE-TRAVEL-RETURN-DURATION;VALUE=DURATION:PT3H
+BEGIN:VALARM
+DESCRIPTION:Event reminder
+TRIGGER:-PT3M
+ACTION:DISPLAY
+END:VALARM
+END:VEVENT
+END:VCALENDAR
+""",
+ """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-1
+DTSTART:20071114T000000Z
+DURATION:PT1H
+DTSTAMP:20071114T000000Z
+ATTENDEE:mailto:user01 at example.com
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user02 at example.com
+ORGANIZER:mailto:user01 at example.com
+RRULE:FREQ=DAILY
+SUMMARY:Test
+TRANSP:TRANSPARENT
+X-APPLE-TRAVEL-DURATION;VALUE=DURATION:PT30M
+END:VEVENT
+BEGIN:VEVENT
+UID:12345-67890-1
+RECURRENCE-ID:20071115T000000Z
+DTSTART:20071115T000000Z
+DURATION:PT1H
+DTSTAMP:20071114T000000Z
+ATTENDEE:mailto:user01 at example.com
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user02 at example.com
+ORGANIZER:mailto:user01 at example.com
+SUMMARY:Test1
+TRANSP:TRANSPARENT
+X-APPLE-TRAVEL-DURATION;VALUE=DURATION:PT30M
+END:VEVENT
+BEGIN:VEVENT
+UID:12345-67890-1
+RECURRENCE-ID:20071116T000000Z
+DTSTART:20071116T000000Z
+DURATION:PT1H
+DTSTAMP:20071114T000000Z
+ATTENDEE:mailto:user01 at example.com
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user02 at example.com
+ORGANIZER:mailto:user01 at example.com
+SUMMARY:Test1
+TRANSP:TRANSPARENT
+X-APPLE-TRAVEL-DURATION;VALUE=DURATION:PT30M
+END:VEVENT
+END:VCALENDAR
+""",
+ ),
+ (
+ "1.2 All DECLINED, with alarm",
+ """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-1
+DTSTART:20071114T000000Z
+DURATION:PT1H
+DTSTAMP:20071114T000000Z
+ATTENDEE:mailto:user01 at example.com
+ATTENDEE;PARTSTAT=DECLINED:mailto:user02 at example.com
+ORGANIZER:mailto:user01 at example.com
+RRULE:FREQ=DAILY
+SUMMARY:Test
+TRANSP:TRANSPARENT
+X-APPLE-TRAVEL-DURATION;VALUE=DURATION:PT30M
+BEGIN:VALARM
+DESCRIPTION:Attendee reminder
+TRIGGER:-PT1M
+ACTION:DISPLAY
+END:VALARM
+END:VEVENT
+END:VCALENDAR
+""",
+ """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+METHOD:REQUEST
+BEGIN:VEVENT
+UID:12345-67890-1
+DTSTART:20071114T000000Z
+DURATION:PT1H
+DTSTAMP:20071114T000000Z
+ATTENDEE:mailto:user01 at example.com
+ATTENDEE;PARTSTAT=DECLINED:mailto:user02 at example.com
+ORGANIZER:mailto:user01 at example.com
+RRULE:FREQ=DAILY
+SUMMARY:Test
+TRANSP:OPAQUE
+X-CALENDARSERVER-PRIVATE-COMMENT:foobar1
+X-APPLE-TRAVEL-DURATION;VALUE=DURATION:PT1H
+X-APPLE-TRAVEL-RETURN-DURATION;VALUE=DURATION:PT1H
+END:VEVENT
+BEGIN:VEVENT
+UID:12345-67890-1
+RECURRENCE-ID:20071115T000000Z
+DTSTART:20071115T000000Z
+DURATION:PT1H
+DTSTAMP:20071114T000000Z
+ATTENDEE:mailto:user01 at example.com
+ATTENDEE;PARTSTAT=DECLINED:mailto:user02 at example.com
+ORGANIZER:mailto:user01 at example.com
+SUMMARY:Test1
+TRANSP:OPAQUE
+X-CALENDARSERVER-PRIVATE-COMMENT:foobar2
+X-APPLE-TRAVEL-DURATION;VALUE=DURATION:PT2H
+X-APPLE-TRAVEL-RETURN-DURATION;VALUE=DURATION:PT2H
+END:VEVENT
+BEGIN:VEVENT
+UID:12345-67890-1
+RECURRENCE-ID:20071116T000000Z
+DTSTART:20071116T000000Z
+DURATION:PT1H
+DTSTAMP:20071114T000000Z
+ATTENDEE:mailto:user01 at example.com
+ATTENDEE;PARTSTAT=DECLINED:mailto:user02 at example.com
+ORGANIZER:mailto:user01 at example.com
+SUMMARY:Test1
+TRANSP:OPAQUE
+X-CALENDARSERVER-PRIVATE-COMMENT:foobar3
+X-APPLE-TRAVEL-DURATION;VALUE=DURATION:PT3H
+X-APPLE-TRAVEL-RETURN-DURATION;VALUE=DURATION:PT3H
+END:VEVENT
+END:VCALENDAR
+""",
+ """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-1
+DTSTART:20071114T000000Z
+DURATION:PT1H
+DTSTAMP:20071114T000000Z
+ATTENDEE:mailto:user01 at example.com
+ATTENDEE;PARTSTAT=DECLINED:mailto:user02 at example.com
+ORGANIZER:mailto:user01 at example.com
+RRULE:FREQ=DAILY
+SUMMARY:Test
+TRANSP:TRANSPARENT
+X-APPLE-TRAVEL-DURATION;VALUE=DURATION:PT30M
+BEGIN:VALARM
+DESCRIPTION:Attendee reminder
+TRIGGER:-PT1M
+ACTION:DISPLAY
+END:VALARM
+END:VEVENT
+BEGIN:VEVENT
+UID:12345-67890-1
+RECURRENCE-ID:20071115T000000Z
+DTSTART:20071115T000000Z
+DURATION:PT1H
+DTSTAMP:20071114T000000Z
+ATTENDEE:mailto:user01 at example.com
+ATTENDEE;PARTSTAT=DECLINED:mailto:user02 at example.com
+ORGANIZER:mailto:user01 at example.com
+SUMMARY:Test1
+TRANSP:TRANSPARENT
+X-APPLE-TRAVEL-DURATION;VALUE=DURATION:PT30M
+BEGIN:VALARM
+DESCRIPTION:Attendee reminder
+TRIGGER:-PT1M
+ACTION:DISPLAY
+END:VALARM
+END:VEVENT
+BEGIN:VEVENT
+UID:12345-67890-1
+RECURRENCE-ID:20071116T000000Z
+DTSTART:20071116T000000Z
+DURATION:PT1H
+DTSTAMP:20071114T000000Z
+ATTENDEE:mailto:user01 at example.com
+ATTENDEE;PARTSTAT=DECLINED:mailto:user02 at example.com
+ORGANIZER:mailto:user01 at example.com
+SUMMARY:Test1
+TRANSP:TRANSPARENT
+X-APPLE-TRAVEL-DURATION;VALUE=DURATION:PT30M
+BEGIN:VALARM
+DESCRIPTION:Attendee reminder
+TRIGGER:-PT1M
+ACTION:DISPLAY
+END:VALARM
+END:VEVENT
+END:VCALENDAR
+""",
+ ),
+ )
+
+ for title, calendar_txt, itip_txt, changed_txt in data:
+ calendar = Component.fromString(calendar_txt)
+ itip = Component.fromString(itip_txt)
+ changed = Component.fromString(changed_txt)
+
+ result, _ignore = iTipProcessing.processRequest(itip, calendar, "mailto:user02 at example.com")
+ self.assertEqual(result, changed, msg="Calendar mismatch: %s" % (title,))
+
+
def test_processReply(self):
"""
Test iTIPProcessing.processReply
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20141106/38d0d102/attachment-0001.html>
More information about the calendarserver-changes
mailing list