changeset 4649da14ae77 in /home/hg/repos/gajim

author: Emmanuel Gil Peyrot <linkma...@linkmauve.fr>
branches: 
details:http://hg.gajim.org/gajim?cmd=changeset;node=4649da14ae77
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 ba35febd92db -r 4649da14ae77 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
 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 @@
         regex = 
re.compile(r"(?P<optname>[^.=]+)(?:(?:\.(?P<key>.+))?\.(?P<subname>[^.=]+))?\s=\s(?P<value>.*)")
 
         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)
_______________________________________________
Commits mailing list
Commits@gajim.org
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to