flatten some config string to str (fixes #10416)

This commit is contained in:
Benjamin Dauvergne 2016-03-24 10:27:23 +01:00
parent 2d11ea7de5
commit 3677cd0c19
1 changed files with 14 additions and 0 deletions

View File

@ -73,6 +73,17 @@ def get_response(env, request, url, cookiejar=None):
return response
def strize(v):
'''Flatten unicode strings to str encoded as UTF-8'''
if isinstance(v, unicode):
return v.encode('utf-8')
if isinstance(v, [list, tuple]):
return type(v)([strize(e) for e in v])
if isinstance(v, dict):
return dict((strize(k), strize(e)) for k, e in v.iteritems())
return v
class MandayeApp(object):
def __init__(self):
@ -115,6 +126,9 @@ class MandayeApp(object):
(param, conf_file)
logger.error(error)
raise ImproperlyConfigured, error
for param in ['location', 'target', 'server_name', 'mapper', 'auth_type']:
if param in conf:
conf[param] = strize(conf[param])
if not config.mappers.has_key(conf['mapper']):
err = '%s: mapper %s not found' % \
(conf_file, conf['mapper'])