[Zope-Checkins] CVS: Zope2 - http_server.py:1.27

chrism@serenade.digicool.com chrism@serenade.digicool.com
Mon, 2 Jul 2001 09:48:46 -0400


Update of /cvs-repository/Zope2/ZServer/medusa
In directory serenade:/home/chrism/BackTalk/ZServer/medusa

Modified Files:
	http_server.py 
Log Message:
Bugfix for logging of username.  Previous revision could raise errors which restarted Zope.


--- Updated File http_server.py in package Zope2 --
--- http_server.py	2001/05/30 16:19:15	1.26
+++ http_server.py	2001/07/02 13:48:46	1.27
@@ -276,10 +276,13 @@
         name='Anonymous'
         if auth is not None:
             if string.lower(auth[:6]) == 'basic ':
-                [name,password] = string.split(
-                    base64.decodestring(
-                    string.split(auth)[-1]), ':')
-  
+                try: decoded=base64.decodestring(auth[6:])
+                except base64.binascii.Error: decoded=''
+                t = string.split(decoded, ':', 1)
+                if len(t) < 2:
+                    name = 'Unknown (bad auth string)'
+                else:
+                    name = t[0]
 
         self.channel.server.logger.log (
             self.channel.addr[0],