Skip to content
Snippets Groups Projects
Commit 1475a1c2 authored by Christophe Simonis's avatar Christophe Simonis
Browse files

[FIX][P3] core: correctly handle binary files (base64 encoded) at rpc level

parent 3a6e7f98
No related branches found
No related tags found
No related merge requests found
......@@ -961,7 +961,10 @@ def start(preload=None, stop=False):
""" Start the odoo http server and cron processor.
"""
global server
load_server_wide_modules()
odoo.service.wsgi_server._patch_xmlrpc_marshaller()
if odoo.evented:
server = GeventServer(odoo.service.wsgi_server.application)
elif config['workers']:
......
......@@ -88,6 +88,17 @@ def xmlrpc_handle_exception_string(e):
return xmlrpclib.dumps(fault, allow_none=None, encoding=None)
def _patch_xmlrpc_marshaller():
# By default, in xmlrpc, bytes are converted to xmlrpclib.Binary object.
# Historically, odoo is sending binary as base64 string.
# In python 3, base64.b64{de,en}code() methods now works on bytes.
# Convert them to str to have a consistent behavior between python 2 and python 3.
# TODO? Create a `/xmlrpc/3` route prefix that respect the standard and uses xmlrpclib.Binary.
def dump_bytes(marshaller, value, write):
marshaller.dump_unicode(odoo.tools.ustr(value), write)
xmlrpclib.Marshaller.dispatch[bytes] = dump_bytes
def wsgi_xmlrpc(environ, start_response):
""" Two routes are available for XML-RPC
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment