mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Fix bytes/string handling in rpc
https://fedorahosted.org/freeipa/ticket/5638 Reviewed-By: Jan Cholasta <jcholast@redhat.com>
This commit is contained in:
committed by
Jan Cholasta
parent
91e5435c8b
commit
831856ea55
@@ -349,7 +349,7 @@ def json_decode_binary(val):
|
||||
elif isinstance(val, list):
|
||||
return tuple(json_decode_binary(v) for v in val)
|
||||
else:
|
||||
if isinstance(val, six.string_types):
|
||||
if isinstance(val, bytes):
|
||||
try:
|
||||
return val.decode('utf-8')
|
||||
except UnicodeDecodeError:
|
||||
@@ -400,7 +400,7 @@ def xml_loads(data, encoding='UTF-8'):
|
||||
|
||||
class DummyParser(object):
|
||||
def __init__(self):
|
||||
self.data = ''
|
||||
self.data = b''
|
||||
|
||||
def feed(self, data):
|
||||
self.data += data
|
||||
@@ -575,7 +575,7 @@ class KerbTransport(SSLTransport):
|
||||
|
||||
if token:
|
||||
extra_headers.append(
|
||||
('Authorization', 'negotiate %s' % base64.b64encode(token))
|
||||
('Authorization', 'negotiate %s' % base64.b64encode(token).decode('ascii'))
|
||||
)
|
||||
|
||||
def _auth_complete(self, response):
|
||||
@@ -586,10 +586,10 @@ class KerbTransport(SSLTransport):
|
||||
k, _, v = field.strip().partition(' ')
|
||||
if k.lower() == 'negotiate':
|
||||
try:
|
||||
token = base64.b64decode(v)
|
||||
token = base64.b64decode(v.encode('ascii'))
|
||||
break
|
||||
# b64decode raises TypeError on invalid input
|
||||
except TypeError:
|
||||
except (TypeError, UnicodeError):
|
||||
pass
|
||||
if not token:
|
||||
raise KerberosError(message="No valid Negotiate header in server response")
|
||||
@@ -1068,12 +1068,12 @@ class JSONServerProxy(object):
|
||||
response = self.__transport.request(
|
||||
self.__host,
|
||||
self.__handler,
|
||||
json.dumps(payload),
|
||||
json.dumps(payload).encode('utf-8'),
|
||||
verbose=self.__verbose >= 3,
|
||||
)
|
||||
|
||||
try:
|
||||
response = json_decode_binary(json.loads(response))
|
||||
response = json_decode_binary(json.loads(response.decode('ascii')))
|
||||
except ValueError as e:
|
||||
raise JSONError(str(e))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user