From 9adba6c5f71a52db6e8851ad1d86add1b5f86634 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Thu, 26 Mar 2015 20:58:51 +0100 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20crash=20when=20the=20config=20f?= =?UTF-8?q?ile=20is=20malformed.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/optparser.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/common/optparser.py b/src/common/optparser.py index a00b00888..19b05451d 100644 --- a/src/common/optparser.py +++ b/src/common/optparser.py @@ -38,6 +38,9 @@ from common import caps_cache import sqlite3 as sqlite from common import logger +import logging +log = logging.getLogger('gajim.c.optparser') + class OptionsParser: def __init__(self, filename): self.__filename = filename @@ -60,7 +63,11 @@ class OptionsParser: regex = re.compile(r"(?P[^.=]+)(?:(?:\.(?P.+))?\.(?P[^.=]+))?\s=\s(?P.*)") for line in fd: - optname, key, subname, value = regex.match(line).groups() + match = regex.match(line) + if match is None: + log.warn('Invalid configuration line, ignoring it: %s', line) + continue + optname, key, subname, value = match.groups() if key is None: self.old_values[optname] = value gajim.config.set(optname, value)