BF: allow newlines in action specifications (e.g. when multiple entries for logpath)

This one should address a crash in #231  but not clear if that would
be the right approach anyways since sendmail-whois-lines would not
function properly anyways
_bf/multiline_action_options
Yaroslav Halchenko 2013-05-14 14:25:47 -04:00
parent 725d666ee6
commit a169ed93f8
2 changed files with 8 additions and 1 deletions

View File

@ -35,7 +35,8 @@ logSys = logging.getLogger("fail2ban.client.config")
class JailReader(ConfigReader):
actionCRE = re.compile("^((?:\w|-|_|\.)+)(?:\[(.*)\])?$")
actionCRE = re.compile("^((?:\w|-|_|\.)+)(?:\[(.*)\])?$",
flags=re.MULTILINE|re.DOTALL)
def __init__(self, name, force_enable=False, **kwargs):
ConfigReader.__init__(self, **kwargs)

View File

@ -110,6 +110,12 @@ class JailReaderTest(unittest.TestCase):
result = JailReader.splitAction(action)
self.assertEquals(expected, result)
def testSplitActionMultiline(self):
action = "mail-whois-lines[logpath=/a/b\n/c/d]"
expected = ['mail-whois-lines', {'logpath': '/a/b\n/c/d'}]
result = JailReader.splitAction(action)
self.assertEquals(expected, result)
class JailsReaderTest(unittest.TestCase):
def testProvidingBadBasedir(self):