1
0

fix parsing values in setconfig (#4225)

This commit is contained in:
ghost43
2018-04-06 18:53:13 +02:00
committed by GitHub
parent bfb0141b20
commit cf88e239d7
2 changed files with 44 additions and 2 deletions

View File

@@ -150,11 +150,20 @@ class Commands:
"""Return a configuration variable. """
return self.config.get(key)
@classmethod
def _setconfig_normalize_value(cls, key, value):
if key not in ('rpcuser', 'rpcpassword'):
value = json_decode(value)
try:
value = ast.literal_eval(value)
except:
pass
return value
@command('')
def setconfig(self, key, value):
"""Set a configuration variable. 'value' may be a string or a Python expression."""
if key not in ('rpcuser', 'rpcpassword'):
value = json_decode(value)
value = self._setconfig_normalize_value(key, value)
self.config.set_key(key, value)
return True