From e3573b48555db6e5271e053f50c4a49d2e367451 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Tue, 3 Sep 2013 17:54:42 +0000 Subject: [PATCH] Bugfix: Avoid passing base64 Basic authorisation through repr --- bitcoinrpc/authproxy.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/bitcoinrpc/authproxy.py b/bitcoinrpc/authproxy.py index 8c56aaf..2914477 100644 --- a/bitcoinrpc/authproxy.py +++ b/bitcoinrpc/authproxy.py @@ -67,9 +67,17 @@ def __init__(self, service_url, service_name=None, timeout=HTTP_TIMEOUT, connect else: port = self.__url.port self.__id_count = 0 - authpair = "%s:%s" % (self.__url.username, self.__url.password) - authpair = authpair.encode('utf8') - self.__auth_header = "Basic %s" % base64.b64encode(authpair) + (user, passwd) = (self.__url.username, self.__url.password) + try: + user = user.encode('utf8') + except AttributeError: + pass + try: + passwd = passwd.encode('utf8') + except AttributeError: + pass + authpair = user + b':' + passwd + self.__auth_header = b'Basic ' + base64.b64encode(authpair) if connection: # Callables re-use the connection of the original proxy