Commit d642df99 authored by Jérome Perrin's avatar Jérome Perrin

*: fix wrong base64 usage

parent 0c4afca5
...@@ -19,8 +19,8 @@ except KeyError: ...@@ -19,8 +19,8 @@ except KeyError:
return result_dict return result_dict
try: try:
encoded = name.replace("definition_view/", "", 1) encoded = name.replace("definition_view/", "", 1).encode()
name = base64.decodebytes(encoded) name = base64.decodebytes(encoded).decode()
base_64 = True base_64 = True
except binascii.Error: except binascii.Error:
pass pass
......
...@@ -55,9 +55,9 @@ class PayzenREST: ...@@ -55,9 +55,9 @@ class PayzenREST:
def callPayzenApi(self, URL, payzen_dict): def callPayzenApi(self, URL, payzen_dict):
base64string = base64.encodebytes( base64string = base64.encodebytes(
'%s:%s' % ( ('%s:%s' % (
self.getServiceUsername(), self.getServiceUsername(),
self.getServiceApiKey())).replace('\n', '') self.getServiceApiKey())).encode()).decode().replace('\n', '')
header = {"Authorization": "Basic %s" % base64string} header = {"Authorization": "Basic %s" % base64string}
LOG('callPayzenApi', WARNING, LOG('callPayzenApi', WARNING,
"data = %s URL = %s" % (str(payzen_dict), URL), error=False) "data = %s URL = %s" % (str(payzen_dict), URL), error=False)
......
...@@ -2,8 +2,8 @@ import base64 ...@@ -2,8 +2,8 @@ import base64
portal = context.getPortalObject() portal = context.getPortalObject()
expense_record_module = portal.getDefaultModule('Expense Record') expense_record_module = portal.getDefaultModule('Expense Record')
sender = portal.portal_membership.getAuthenticatedMember().getUserValue() sender = portal.portal_membership.getAuthenticatedMember().getUserValue()
data = context.getData() data = bytes(context.getData())
data64 = u''.join(base64.encodebytes(data).splitlines()) data64 = u''.join(base64.encodebytes(data).decode().splitlines())
photo_data = u'data:%s;base64,%s' % ("image/*", data64) photo_data = u'data:%s;base64,%s' % ("image/*", data64)
expense_record_module.newContent( expense_record_module.newContent(
comment=comment, comment=comment,
......
...@@ -45,7 +45,7 @@ zope_url = url.rsplit('/', 2)[0] ...@@ -45,7 +45,7 @@ zope_url = url.rsplit('/', 2)[0]
import base64 import base64
browser.mech_browser.addheaders.append( browser.mech_browser.addheaders.append(
('Authorization', ('Authorization',
'Basic %s' % base64.encodebytes('%s:%s' % (username, password)))) 'Basic %s' % base64.encodebytes(('%s:%s' % (username, password)).encode())).decode())
for index in range(user_nbr): for index in range(user_nbr):
new_username = "%s%d" % (new_username_prefix, index) new_username = "%s%d" % (new_username_prefix, index)
......
...@@ -4,7 +4,7 @@ import six.moves.http_client ...@@ -4,7 +4,7 @@ import six.moves.http_client
connection = six.moves.http_client.HTTPConnection('192.168.242.68:12001') connection = six.moves.http_client.HTTPConnection('192.168.242.68:12001')
import base64 import base64
base64string = base64.encodebytes('zope:insecure')[:-1] base64string = base64.encodebytes(b'zope:insecure').decode()[:-1]
n = 1 << 20 n = 1 << 20
......
...@@ -77,7 +77,7 @@ if IS_ZOPE2: # BBB ...@@ -77,7 +77,7 @@ if IS_ZOPE2: # BBB
except AttributeError: except AttributeError:
pass pass
else: else:
medusa_headers['authorization'] = 'Basic %s' % encodebytes('%s:' % username).rstrip() medusa_headers['authorization'] = 'Basic %s' % encodebytes(('%s:' % username).encode()).decode().rstrip()
else: else:
REQUEST._orig_env['REMOTE_USER'] = username REQUEST._orig_env['REMOTE_USER'] = username
else: # zope4 else: # zope4
...@@ -87,7 +87,6 @@ else: # zope4 ...@@ -87,7 +87,6 @@ else: # zope4
""" """
pass pass
def initialize(context): def initialize(context):
from . import ( from . import (
ERP5UserManager, ERP5UserManager,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment