diff --git a/fail2ban/client/configparserinc.py b/fail2ban/client/configparserinc.py index 679fcecc..7519e599 100644 --- a/fail2ban/client/configparserinc.py +++ b/fail2ban/client/configparserinc.py @@ -100,6 +100,7 @@ after = 1.conf def __init__(self, *args, **kwargs): kwargs = kwargs.copy() kwargs['interpolation'] = BasicInterpolationWithName() + kwargs['inline_comment_prefixes'] = ";" super(SafeConfigParserWithIncludes, self).__init__( *args, **kwargs) diff --git a/fail2ban/tests/clientreadertestcase.py b/fail2ban/tests/clientreadertestcase.py index d45efb46..7b88d029 100644 --- a/fail2ban/tests/clientreadertestcase.py +++ b/fail2ban/tests/clientreadertestcase.py @@ -131,6 +131,18 @@ z = 3%(__name__)s self.assertEqual(self.c.get('section', 'zz'), 'thesection') # __name__ works even 'delayed' self.assertEqual(self.c.get('section2', 'z'), '3section2') # and differs per section ;) + def testComments(self): + self.assertFalse(self.c.read('g')) # nothing is there yet + self._write("g.conf", value=None, content=""" +[DEFAULT] +# A comment +b = a +c = d ;in line comment +""") + self.assertTrue(self.c.read('g')) + self.assertEqual(self.c.get('DEFAULT', 'b'), 'a') + self.assertEqual(self.c.get('DEFAULT', 'c'), 'd') + class JailReaderTest(unittest.TestCase): def testIncorrectJail(self):