fixes precise year pattern %ExY - accept years 20xx up to current century (using almost the same pattern in tests and production now)

pull/3117/head
sebres 2021-05-07 01:10:26 +02:00
parent 319cfefac2
commit 2918849f9e
1 changed files with 8 additions and 8 deletions

View File

@ -104,13 +104,13 @@ def _updateTimeRE():
# more precise year patterns, within same century of last year and # more precise year patterns, within same century of last year and
# the next 3 years (for possible long uptime of fail2ban); thereby # the next 3 years (for possible long uptime of fail2ban); thereby
# respect possible run in the test-cases (alternate date used there): # consider possible run in the test-cases (alternate date used there),
if MyTime.alternateNowTime != 0: # so accept years: 20xx (from test-date or 2001 up to current century)
timeRE['ExY'] = r"(?P<Y>%s\d)" % _getYearCentRE(cent=(0,3), distance=3) timeRE['ExY'] = r"(?P<Y>%s\d)" % _getYearCentRE(cent=(0,3), distance=3,
timeRE['Exy'] = r"(?P<y>%s\d)" % _getYearCentRE(cent=(2,3), distance=3) now=(datetime.datetime.now(), datetime.datetime.fromtimestamp(
else: # accept years: 19xx|2xxx up to current century min(MyTime.alternateNowTime or 978393600, 978393600))
timeRE['ExY'] = r"(?P<Y>(?:19\d{2}|%s\d))" % _getYearCentRE(cent=(0,3), distance=3, )
now=(MyTime.now(), datetime.datetime.fromtimestamp(978393600))) )
timeRE['Exy'] = r"(?P<y>\d{2})" timeRE['Exy'] = r"(?P<y>\d{2})"
_updateTimeRE() _updateTimeRE()