From b3db013754b8ce9d39828bc6de61859831ecfed0 Mon Sep 17 00:00:00 2001 From: Daniel Kahn Gillmor Date: Tue, 19 Feb 2019 17:16:26 -0500 Subject: [PATCH] config: Reassemble strings sensibly If a string-based configuation entry had whitespace in it, it would be reassembled via a round-trip through the python interpreter, resulting in a line like this: PidFile /home/dkimpy-milter/pid file produces a string like "['/home/dkimpy-milter/pid', 'file']", which is clearly wrong. I don't want to encourage people to use paths or other strings with whitespace in them, but if we're going to fail on them we should be failing explicitly, not doing a weird transformation that will just break. This is concretely useful for the DNSOverride mechanism, which is where i ran into the problem when trying to set up testing that could work without setting up an emulated DNS system. --- dkimpy_milter/config.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dkimpy_milter/config.py b/dkimpy_milter/config.py index 601017a..d562e97 100644 --- a/dkimpy_milter/config.py +++ b/dkimpy_milter/config.py @@ -390,7 +390,10 @@ def _readConfigFile(path, configData=None, configGlobal={}): if conversion == 'bool': configData[name] = _find_boolean(value) elif conversion == 'str': - configData[name] = str(value) + if isinstance(value, list): + configData[name] = line.split(None, 1)[1] + else: + configData[name] = str(value) elif conversion == 'int': configData[name] = int(value) elif conversion == 'dataset':