[CalendarServer-changes] [2999] CalendarServer/trunk/twistedcaldav/resource.py

source_changes at macosforge.org source_changes at macosforge.org
Mon Sep 15 12:28:15 PDT 2008


Revision: 2999
          http://trac.macosforge.org/projects/calendarserver/changeset/2999
Author:   wsanchez at apple.com
Date:     2008-09-15 12:28:14 -0700 (Mon, 15 Sep 2008)
Log Message:
-----------
Catch TypeError from re.search and try emit some useful information about why

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/resource.py

Modified: CalendarServer/trunk/twistedcaldav/resource.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/resource.py	2008-09-15 19:16:38 UTC (rev 2998)
+++ CalendarServer/trunk/twistedcaldav/resource.py	2008-09-15 19:28:14 UTC (rev 2999)
@@ -157,14 +157,19 @@
             # Filter out unsupported clients
             #
             agent = request.headers.getHeader("user-agent")
-            if agent:
+            if agent is not None:
                 for reject in config.RejectClients:
-                    if reject.search(agent) is not None:
-                        self.log_info("Rejecting user-agent: %s" % (agent,))
-                        raise HTTPError(StatusResponse(
-                            responsecode.FORBIDDEN,
-                            "Your client software (%s) is not allowed to access this service." % (agent,)
-                        ))
+                    try:
+                        result = reject.search(agent)
+                    except TypeError:
+                        raise AssertionError("User-agent is not a string: (%s) %r", type(agent), agent)
+                    else:
+                        if result is not None:
+                            self.log_info("Rejecting user-agent: %s" % (agent,))
+                            raise HTTPError(StatusResponse(
+                                responsecode.FORBIDDEN,
+                                "Your client software (%s) is not allowed to access this service." % (agent,)
+                            ))
 
         response = maybeDeferred(super(CalDAVResource, self).renderHTTP, request)
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20080915/3a828dcb/attachment.html 


More information about the calendarserver-changes mailing list