aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@gmail.com>2011-05-16 20:18:38 -0400
committerGuillaume Horel <guillaume.horel@gmail.com>2011-05-16 20:18:38 -0400
commit1e5d2ca7df87c5365908106fce493cf81edbec75 (patch)
tree12d07f62e29249ab96f5d25348bccdfd93352c3a
parentd137a319efc660e201ce227bf2e9e762edab5207 (diff)
downloadalias-1e5d2ca7df87c5365908106fce493cf81edbec75.tar.gz
Catch exception when handling base64 strings
-rw-r--r--server/user.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/server/user.py b/server/user.py
index 383085d..1cb2d63 100644
--- a/server/user.py
+++ b/server/user.py
@@ -12,7 +12,7 @@ class User:
def __init__(self, jid):
self.jid = jid
#self.hash = hashlib.sha1(jid).hexdigest()
- self.hash = base64.encodestring(jid)
+ self.hash = base64.b64encode(jid)
def register(self, registration):
ObjectWriter(self.hash).create_root_object(self.jid, registration)
@@ -37,7 +37,10 @@ class UserHandler:
result = []
for stem in os.listdir(self.root):
for leaf in os.listdir(os.path.join(self.root, stem)):
- result.append(base64.decodestring(stem + leaf))
+ try:
+ result.append(base64.b64decode(stem + leaf))
+ except TypeError:
+ logger.error("User tree corrupted")
return result
if __name__ == '__main__':