unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
blob 91d973e72e07bd4ebfaaa6a9bc3448140a5b2e28 1771 bytes (raw)
name: packages/patches/fail2ban-0.11.2_fix-test-suite.patch 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
 
From 747d4683221b5584f9663695fb48145689b42ceb Mon Sep 17 00:00:00 2001
From: sebres <info@sebres.de>
Date: Mon, 4 Jan 2021 02:42:38 +0100
Subject: [PATCH] fixes century selector of %ExY and %Exy in datepattern for
 tests, considering interval from 2005 (alternate now) to now; + better
 grouping algorithm for resulting century RE

---
 fail2ban/server/strptime.py | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/fail2ban/server/strptime.py b/fail2ban/server/strptime.py
index 1464a96d1f..39fc795865 100644
--- a/fail2ban/server/strptime.py
+++ b/fail2ban/server/strptime.py
@@ -36,10 +36,30 @@ def _getYearCentRE(cent=(0,3), distance=3, now=(MyTime.now(), MyTime.alternateNo
 	Thereby respect possible run in the test-cases (alternate date used there)
 	"""
 	cent = lambda year, f=cent[0], t=cent[1]: str(year)[f:t]
+	def grp(exprset):
+		c = None
+		if len(exprset) > 1:
+			for i in exprset:
+				if c is None or i[0:-1] == c:
+					c = i[0:-1]
+				else:
+					c = None
+					break
+			if not c:
+				for i in exprset:
+					if c is None or i[0] == c:
+						c = i[0]
+					else:
+						c = None
+						break
+			if c:
+				return "%s%s" % (c, grp([i[len(c):] for i in exprset]))
+		return ("(?:%s)" % "|".join(exprset) if len(exprset[0]) > 1 else "[%s]" % "".join(exprset)) \
+			if len(exprset) > 1 else "".join(exprset)
 	exprset = set( cent(now[0].year + i) for i in (-1, distance) )
 	if len(now) and now[1]:
-		exprset |= set( cent(now[1].year + i) for i in (-1, distance) )
-	return "(?:%s)" % "|".join(exprset) if len(exprset) > 1 else "".join(exprset)
+		exprset |= set( cent(now[1].year + i) for i in xrange(-1, now[0].year-now[1].year+1, distance) )
+	return grp(sorted(list(exprset)))
 
 timeRE = TimeRE()
 

debug log:

solving 91d973e72e07bd4ebfaaa6a9bc3448140a5b2e28 ...
found 91d973e72e07bd4ebfaaa6a9bc3448140a5b2e28 in https://git.savannah.gnu.org/cgit/guix.git

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).