electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 6958c0ccc3d97edfb7f8504f27270182cb3abcfa
parent ef2a6359e4521cef4302486a2b9844814938babf
Author: SomberNight <somber.night@protonmail.com>
Date:   Sun, 21 Oct 2018 14:58:55 +0200

config: reject non-json-serialisable writes

see #4788

Diffstat:
Melectrum/simple_config.py | 6++++++
Melectrum/storage.py | 2+-
2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/electrum/simple_config.py b/electrum/simple_config.py @@ -140,6 +140,12 @@ class SimpleConfig(PrintError): if not self.is_modifiable(key): self.print_stderr("Warning: not changing config key '%s' set on the command line" % key) return + try: + json.dumps(key) + json.dumps(value) + except: + self.print_error(f"json error: cannot save {repr(key)} ({repr(value)})") + return self._set_key_in_user_config(key, value, save) def _set_key_in_user_config(self, key, value, save=True): diff --git a/electrum/storage.py b/electrum/storage.py @@ -90,7 +90,7 @@ class JsonDB(PrintError): json.dumps(key, cls=util.MyEncoder) json.dumps(value, cls=util.MyEncoder) except: - self.print_error("json error: cannot save", key) + self.print_error(f"json error: cannot save {repr(key)} ({repr(value)})") return with self.db_lock: if value is not None: