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

source_changes at macosforge.org source_changes at macosforge.org
Tue Oct 21 11:52:37 PDT 2008


Revision: 3200
          http://trac.macosforge.org/projects/calendarserver/changeset/3200
Author:   sagen at apple.com
Date:     2008-10-21 11:52:35 -0700 (Tue, 21 Oct 2008)
Log Message:
-----------
mailto: CUAddrs are normalized to lowercase, whereas http URLs are not

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/directory/directory.py
    CalendarServer/trunk/twistedcaldav/ical.py
    CalendarServer/trunk/twistedcaldav/scheduling/cuaddress.py

Modified: CalendarServer/trunk/twistedcaldav/directory/directory.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/directory.py	2008-10-21 16:09:47 UTC (rev 3199)
+++ CalendarServer/trunk/twistedcaldav/directory/directory.py	2008-10-21 18:52:35 UTC (rev 3200)
@@ -37,6 +37,7 @@
 from twistedcaldav.log import LoggingMixIn
 from twistedcaldav.directory.idirectory import IDirectoryService, IDirectoryRecord
 from twistedcaldav.directory.util import uuidFromName
+from twistedcaldav.scheduling.cuaddress import normalizeCUAddr
 
 class DirectoryService(LoggingMixIn):
     implements(IDirectoryService, ICredentialsChecker)
@@ -128,7 +129,7 @@
         return None
 
     def recordWithCalendarUserAddress(self, address):
-        address = address.lower()
+        address = normalizeCUAddr(address)
         for record in self.allRecords():
             if address in record.calendarUserAddresses:
                 return record

Modified: CalendarServer/trunk/twistedcaldav/ical.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/ical.py	2008-10-21 16:09:47 UTC (rev 3199)
+++ CalendarServer/trunk/twistedcaldav/ical.py	2008-10-21 18:52:35 UTC (rev 3200)
@@ -35,6 +35,7 @@
 from twisted.web2.dav.util import allDataFromStream
 from twisted.web2.stream import IStream
 from twistedcaldav.dateops import compareDateTime, normalizeToUTC, timeRangesOverlap
+from twistedcaldav.scheduling.cuaddress import normalizeCUAddr
 from twistedcaldav.instance import InstanceList
 from twistedcaldav.log import Logger
 from vobject import newFromBehavior, readComponents
@@ -1214,19 +1215,10 @@
         @return: the matching Attendee property, or None
         """
         
-        # FIXME: we should really have a URL class and have it manage comparisons
-        # in a sensible fashion.
-        def _normalizeCUAddress(addr):
-            addr = addr.lower()
-            if addr.startswith("/") or addr.startswith("http:") or addr.startswith("https:"):
-                return addr.rstrip("/")
-            else:
-                return addr
-
         # Need to normalize http/https cu addresses
         test = set()
         for item in match:
-            test.add(_normalizeCUAddress(item))
+            test.add(normalizeCUAddr(item))
         
         # Extract appropriate sub-component if this is a VCALENDAR
         if self.name() == "VCALENDAR":
@@ -1238,7 +1230,7 @@
         else:
             # Find the primary subcomponent
             for attendee in self.properties("ATTENDEE"):
-                if _normalizeCUAddress(attendee.value()) in test:
+                if normalizeCUAddr(attendee.value()) in test:
                     return attendee
 
         return None

Modified: CalendarServer/trunk/twistedcaldav/scheduling/cuaddress.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/cuaddress.py	2008-10-21 16:09:47 UTC (rev 3199)
+++ CalendarServer/trunk/twistedcaldav/scheduling/cuaddress.py	2008-10-21 18:52:35 UTC (rev 3200)
@@ -22,6 +22,7 @@
     "RemoteCalendarUser",
     "EmailCalendarUser",
     "InvalidCalendarUser",
+    "normalizeCUAddr",
 ]
 
 log = Logger()
@@ -75,3 +76,20 @@
     def __str__(self):
         return "Invalid calendar user: %s" % (self.cuaddr,)
 
+
+def normalizeCUAddr(addr):
+    """
+    Normalize a cuaddr string by lower()ing it if it's a mailto:, or
+    removing trailing slash if it's a URL.
+    @param addr: a cuaddr string to normalize
+    @return: normalized string
+    """
+    lower = addr.lower()
+    if lower.startswith("mailto:"):
+        addr = lower
+    if (addr.startswith("/") or
+        addr.startswith("http:") or
+        addr.startswith("https:")):
+        return addr.rstrip("/")
+    else:
+        return addr
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20081021/53abc943/attachment.html 


More information about the calendarserver-changes mailing list