Commit b029d555 authored by Łukasz Nowak's avatar Łukasz Nowak

taskdistribution: Wrap in xmlrpclib.Binary if needed

In order to safely use non-XML allowed characters coming from various
sources wrap basestring into xmlrpclib.Binary before sending it to the
server.
parent 13c0f2e1
......@@ -95,6 +95,16 @@ def patchRPCParser(error_handler):
raise
parser_klass.feed = verbose_feed
def binarize_args(arg):
# Converts recursively basestring arg into Binary
if isinstance(arg, basestring):
return xmlrpclib.Binary(arg.encode('utf-8'))
if isinstance(arg, (list, tuple)):
return map(binarize_args, arg)
if isinstance(arg, dict):
return {k: binarize_args(v) for k, v in arg.iteritems()}
return arg
class RPCRetry(object):
def __init__(self, proxy, retry_time, logger):
super(RPCRetry, self).__init__()
......@@ -107,6 +117,9 @@ class RPCRetry(object):
def _retryRPC(self, func_id, args=()):
retry_time = self._retry_time
# Wrap basestrings into xmlrpclib.Binary, as they can contain
# non-XML allowed characters
args = binarize_args(args)
while True:
try:
return self._RPC(func_id, args)
......
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