changeset 7ff6c8bcae13 in /home/hg/repos/gajim
author: Emmanuel Gil Peyrot linkmauve@linkmauve.fr branches: gajim_0.16 details:http://hg.gajim.org/gajim?cmd=changeset;node=7ff6c8bcae13 description: Don’t crash when the config file is malformed.
diffstat:
src/common/optparser.py | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-)
diffs (26 lines):
diff -r e0e36580b786 -r 7ff6c8bcae13 src/common/optparser.py --- a/src/common/optparser.py Wed Mar 25 10:05:29 2015 +0100 +++ b/src/common/optparser.py Thu Mar 26 20:58:51 2015 +0100 @@ -38,6 +38,9 @@ import sqlite3 as sqlite import logger
+import logging +log = logging.getLogger('gajim.c.optparser') + class OptionsParser: def __init__(self, filename): self.__filename = filename @@ -63,7 +66,11 @@ line = line.decode('utf-8') except UnicodeDecodeError: line = line.decode(locale.getpreferredencoding()) - 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)