--- a/web/request.py Tue Oct 06 11:14:15 2015 +0200
+++ b/web/request.py Tue Oct 06 11:15:56 2015 +0200
@@ -846,7 +846,7 @@
scheme = scheme.lower()
try:
assert scheme == "basic"
- user, passwd = base64.decodestring(rest).split(":", 1)
+ user, passwd = base64.decodestring(rest.encode('ascii')).split(b":", 1)
# XXX HTTP header encoding: use email.Header?
return user.decode('UTF8'), passwd
except Exception as ex:
--- a/web/test/unittest_application.py Tue Oct 06 11:14:15 2015 +0200
+++ b/web/test/unittest_application.py Tue Oct 06 11:15:56 2015 +0200
@@ -317,8 +317,8 @@
self.app.handle_request(req, 'login')
self.assertEqual(401, req.status_out)
clear_cache(req, 'get_authorization')
- authstr = base64.encodestring('%s:%s' % (self.admlogin, self.admpassword))
- req.set_request_header('Authorization', 'basic %s' % authstr)
+ authstr = base64.encodestring(('%s:%s' % (self.admlogin, self.admpassword)).encode('ascii'))
+ req.set_request_header('Authorization', 'basic %s' % authstr.decode('ascii'))
self.assertAuthSuccess(req, origsession)
self.assertRaises(LogOut, self.app_handle_request, req, 'logout')
self.assertEqual(len(self.open_sessions), 0)
@@ -393,11 +393,11 @@
def test_http_auth_anon_allowed(self):
req, origsession = self.init_authentication('http', 'anon')
self._test_auth_anon(req)
- authstr = base64.encodestring('toto:pouet')
- req.set_request_header('Authorization', 'basic %s' % authstr)
+ authstr = base64.encodestring(b'toto:pouet')
+ req.set_request_header('Authorization', 'basic %s' % authstr.decode('ascii'))
self._test_anon_auth_fail(req)
- authstr = base64.encodestring('%s:%s' % (self.admlogin, self.admpassword))
- req.set_request_header('Authorization', 'basic %s' % authstr)
+ authstr = base64.encodestring(('%s:%s' % (self.admlogin, self.admpassword)).encode('ascii'))
+ req.set_request_header('Authorization', 'basic %s' % authstr.decode('ascii'))
self.assertAuthSuccess(req, origsession)
self.assertRaises(LogOut, self.app_handle_request, req, 'logout')
self.assertEqual(len(self.open_sessions), 0)