[CalendarServer-changes] [3214] CalendarServer/trunk/twistedcaldav

source_changes at macosforge.org source_changes at macosforge.org
Wed Oct 22 20:04:45 PDT 2008


Revision: 3214
          http://trac.macosforge.org/projects/calendarserver/changeset/3214
Author:   cdaboo at apple.com
Date:     2008-10-22 20:04:44 -0700 (Wed, 22 Oct 2008)
Log Message:
-----------
Make sure unknown X- properties do not get sent in scheduling messages.

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/ical.py
    CalendarServer/trunk/twistedcaldav/scheduling/icaldiff.py
    CalendarServer/trunk/twistedcaldav/scheduling/itip.py
    CalendarServer/trunk/twistedcaldav/scheduling/test/test_icaldiff.py

Modified: CalendarServer/trunk/twistedcaldav/ical.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/ical.py	2008-10-22 23:44:29 UTC (rev 3213)
+++ CalendarServer/trunk/twistedcaldav/ical.py	2008-10-23 03:04:44 UTC (rev 3214)
@@ -1470,26 +1470,25 @@
         else:
             if self.name() == "VTIMEZONE":
                 return
-            if keep:
-                [self.removeProperty(p) for p in tuple(self.properties()) if p.name() not in keep]
-            if remove:
-                [self.removeProperty(p) for p in tuple(self.properties()) if p.name() in remove]
+            
+            for p in tuple(self.properties()):
+                if (keep and p.name() not in keep) or (remove and p.name() in remove):
+                    self.removeProperty(p)
                 
-    def removeXProperties(self, keep_properties=()):
+    def removeXProperties(self, keep_properties=(), do_subcomponents=True):
         """
         Remove all X- properties except the specified ones
         """
 
-        assert self.name() == "VCALENDAR", "Not a calendar: %r" % (self,)
-
-        for component in self.subcomponents():
-            if component.name() == "VTIMEZONE":
-                continue
-            [
-                component.removeProperty(p)
-                for p in tuple(component.properties())
-                if p.name().startswith("X-") and p.name() not in keep_properties
-            ]
+        if do_subcomponents:
+            for component in self.subcomponents():
+                component.removeXProperties(keep_properties, do_subcomponents=False)
+        else:
+            if self.name() == "VTIMEZONE":
+                return
+            for p in tuple(self.properties()):
+                if p.name().startswith("X-") and p.name() not in keep_properties:
+                    self.removeProperty(p)
             
     def removePropertyParameters(self, property, params):
         """

Modified: CalendarServer/trunk/twistedcaldav/scheduling/icaldiff.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/icaldiff.py	2008-10-22 23:44:29 UTC (rev 3213)
+++ CalendarServer/trunk/twistedcaldav/scheduling/icaldiff.py	2008-10-23 03:04:44 UTC (rev 3214)
@@ -89,8 +89,7 @@
             calendar = calendar.duplicate()
             calendar.normalizePropertyValueLists("EXDATE")
             calendar.removePropertyParameters("ORGANIZER", ("SCHEDULE-STATUS",))
-            calendar.removeXProperties(("X-CALENDARSERVER-PRIVATE-COMMENT",))
-            iTipGenerator.prepareSchedulingMessage(calendar)
+            iTipGenerator.prepareSchedulingMessage(calendar, reply=True)
             return calendar
 
         # Do straight comparison without alarms

Modified: CalendarServer/trunk/twistedcaldav/scheduling/itip.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/itip.py	2008-10-22 23:44:29 UTC (rev 3213)
+++ CalendarServer/trunk/twistedcaldav/scheduling/itip.py	2008-10-23 03:04:44 UTC (rev 3214)
@@ -557,12 +557,12 @@
         itip.addPropertyToAllComponents(Property("REQUEST-STATUS", ["2.0", "Success",]))
         
         # Strip out unwanted bits
-        iTipGenerator.prepareSchedulingMessage(itip)
+        iTipGenerator.prepareSchedulingMessage(itip, reply=True)
 
         return itip
 
     @staticmethod
-    def prepareSchedulingMessage(itip):
+    def prepareSchedulingMessage(itip, reply=False):
         """
         Remove properties and parameters that should not be sent in an iTIP message
         """
@@ -570,11 +570,12 @@
         # Alarms
         itip.removeAlarms()
 
-        # Top-level properties
-        itip.filterProperties(remove=("X-CALENDARSERVER-ACCESS",), do_subcomponents=False)
+        # Top-level properties - remove all X-
+        itip.removeXProperties(do_subcomponents=False)
                 
-        # Component properties
-        itip.filterProperties(remove=("X-CALENDARSERVER-ATTENDEE-COMMENT",))
+        # Component properties - remove all X- except for those specified
+        keep_properties = ("X-CALENDARSERVER-PRIVATE-COMMENT",) if reply else ()
+        itip.removeXProperties(keep_properties=keep_properties)
         
         # Property Parameters
         itip.removePropertyParameters("ATTENDEE", ("SCHEDULE-AGENT", "SCHEDULE-STATUS",))

Modified: CalendarServer/trunk/twistedcaldav/scheduling/test/test_icaldiff.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/test/test_icaldiff.py	2008-10-22 23:44:29 UTC (rev 3213)
+++ CalendarServer/trunk/twistedcaldav/scheduling/test/test_icaldiff.py	2008-10-23 03:04:44 UTC (rev 3214)
@@ -691,7 +691,7 @@
 END:VCALENDAR
 """,
                 "mailto:user2 at example.com",
-                (False, False,)
+                (True, True,)
             ),
             (
                 "#1.7 Simple component, vtimezone no change",
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20081022/f78a5d52/attachment-0001.html>


More information about the calendarserver-changes mailing list