From 3e8098d4274b5f00585c201b57bc7165f02c3218 Mon Sep 17 00:00:00 2001 From: sebres Date: Tue, 30 Jan 2018 15:10:17 +0100 Subject: [PATCH] python 3.x compatibility: fix replacement string (may fail with errors like `bad escape \d ...`, etc) --- fail2ban/server/datetemplate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fail2ban/server/datetemplate.py b/fail2ban/server/datetemplate.py index 4c9bb4e37..cd4592c77 100644 --- a/fail2ban/server/datetemplate.py +++ b/fail2ban/server/datetemplate.py @@ -204,7 +204,7 @@ class DateEpoch(DateTemplate): self.name = "LongEpoch"; epochRE = r"\d{10,11}(?:\d{3}(?:\d{3})?)?" if pattern: - regex = RE_EPOCH_PATTERN.sub("(%s)" % epochRE, pattern) + regex = RE_EPOCH_PATTERN.sub(lambda v: "(%s)" % epochRE, pattern) self.setRegex(regex) elif not lineBeginOnly: regex = r"((?:^|(?P(?<=^\[))|(?P(?<=\baudit\()))%s)(?:(?(selinux)(?=:\d+\)))|(?(square)(?=\])))" % epochRE