]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fixed #27251: corrected string/bytes handling in credentials.
authorVinay Sajip <vinay_sajip@yahoo.co.uk>
Tue, 7 Jun 2016 20:19:55 +0000 (21:19 +0100)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>
Tue, 7 Jun 2016 20:19:55 +0000 (21:19 +0100)
Lib/logging/handlers.py
Lib/test/test_logging.py

index c6840c30b35b2bc0a19d90761e8d89730f922f25..c9f8217b06b4a937d3177c39bee0b6ace8bbf1bc 100644 (file)
@@ -1156,8 +1156,8 @@ class HTTPHandler(logging.Handler):
                 h.putheader("Content-length", str(len(data)))
             if self.credentials:
                 import base64
-                s = ('u%s:%s' % self.credentials).encode('utf-8')
-                s = 'Basic ' + base64.b64encode(s).strip()
+                s = ('%s:%s' % self.credentials).encode('utf-8')
+                s = 'Basic ' + base64.b64encode(s).strip().decode('ascii')
                 h.putheader('Authorization', s)
             h.endheaders()
             if self.method == "POST":
index 95575bf56a63be10382c9684f56f2a7688bbad2d..84fd8b57c73be0fc40368a75977f72b23b74e9fb 100644 (file)
@@ -1672,7 +1672,8 @@ class HTTPHandlerTest(BaseTest):
             secure_client = secure and sslctx
             self.h_hdlr = logging.handlers.HTTPHandler(host, '/frob',
                                                        secure=secure_client,
-                                                       context=context)
+                                                       context=context,
+                                                       credentials=('foo', 'bar'))
             self.log_data = None
             root_logger.addHandler(self.h_hdlr)