web/webconfig.py
branchstable
changeset 9326 9d145b4c4e53
parent 9317 0f2b80078aeb
child 9340 b1e933b0e850
--- a/web/webconfig.py	Thu Nov 07 11:20:59 2013 +0100
+++ b/web/webconfig.py	Tue Nov 12 15:24:57 2013 +0100
@@ -296,6 +296,9 @@
 
     def sign_text(self, text):
         """sign some text for later checking"""
+        # hmac.new expect bytes
+        if isinstance(text, unicode):
+            text = text.encode('utf-8')
         # replace \r\n so we do not depend on whether a browser "reencode"
         # original message using \r\n or not
         return hmac.new(self._instance_salt,
@@ -305,7 +308,6 @@
         """check the text signature is equal to the given signature"""
         return self.sign_text(text) == signature
 
-
     def locate_resource(self, rid):
         """return the (directory, filename) where the given resource
         may be found