From fd8788dd348cebdf8d21dfae5fb6031b26848dc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 6 Feb 2019 16:06:56 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=20More=20error=20resilience=20for=20e?= =?UTF-8?q?ncoding=20issues=20in=20config.yaml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Normally I'd say, broken files are broken files, but since in case of an encoding error in config.yaml the server won't come up anymore we are erring on the side of caution here and running with errors="replace" --- src/octoprint/settings.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/octoprint/settings.py b/src/octoprint/settings.py index b4f58e5d2..2c9abf869 100644 --- a/src/octoprint/settings.py +++ b/src/octoprint/settings.py @@ -888,7 +888,7 @@ class Settings(object): def load(self, migrate=False): if os.path.exists(self._configfile) and os.path.isfile(self._configfile): - with io.open(self._configfile, 'rt', encoding='utf-8') as f: + with io.open(self._configfile, 'rt', encoding='utf-8', errors='replace') as f: try: self._config = yaml.safe_load(f) self._mtime = self.last_modified @@ -927,7 +927,7 @@ class Settings(object): if isinstance(overlay, basestring): if os.path.exists(overlay) and os.path.isfile(overlay): - with io.open(overlay, 'rt', encoding='utf-8') as f: + with io.open(overlay, 'rt', encoding='utf-8', errors='replace') as f: config = yaml.safe_load(f) elif isinstance(overlay, dict): config = overlay