diff wiki/middleware.py @ 1174:ba3230aba90c

Fix unicode error with wiki cookie processing
author Brian Neal <bgneal@gmail.com>
date Thu, 07 Jun 2018 19:53:13 -0500
parents 47521d9e94bd
children
line wrap: on
line diff
--- a/wiki/middleware.py	Sat Apr 14 14:03:04 2018 -0500
+++ b/wiki/middleware.py	Thu Jun 07 19:53:13 2018 -0500
@@ -23,16 +23,18 @@
 
     # The key part of the cookie is just a string that would make things
     # difficult for a spoofer; something that can't be easily made up:
+    username = user.username.encode('utf-8')
+    email = user.email.encode('utf-8')
 
     h = hashlib.sha256()
-    h.update(user.username.encode('utf-8'))
-    h.update(user.email.encode('utf-8'))
+    h.update(username)
+    h.update(email)
     h.update(now.isoformat())
     h.update(''.join(random.sample(string.printable, 64)))
     h.update(settings.SECRET_KEY)
     key = h.hexdigest()
 
-    parts = (user.username, user.email, key)
+    parts = (username, email, key)
     return '#'.join(parts)