Merge pull request #47966 from mbunkus/fix-postfix-prefix-free-key-names-assumption

Fix postfix.set_main's assumption of prefix-free key names
This commit is contained in:
Nicole Thomas 2018-06-06 11:43:23 -04:00 committed by GitHub
commit 998a1c13d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -288,9 +288,10 @@ def set_main(key, value, path=MAIN_CF):
pairs, conf_list = _parse_main(path)
new_conf = []
key_line_match = re.compile("^{0}([\\s=]|$)".format(re.escape(key)))
if key in pairs:
for line in conf_list:
if line.startswith(key):
if re.match(key_line_match, line):
new_conf.append('{0} = {1}'.format(key, value))
else:
new_conf.append(line)