[3.9] bpo-45628: Check all parts of the suffix for an extension match. (GH-29310) (GH-29313)

This commit is contained in:
Miss Islington (bot) 2021-10-29 08:24:41 -07:00 committed by GitHub
parent a043706f90
commit 317e0c99e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -368,8 +368,13 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
for fileName in fileNames:
if fileName[:plen] == prefix:
suffix = fileName[plen:]
if self.extMatch.match(suffix):
result.append(os.path.join(dirName, fileName))
# See bpo-45628: The date/time suffix could be anywhere in the
# filename
parts = suffix.split('.')
for part in parts:
if self.extMatch.match(part):
result.append(os.path.join(dirName, fileName))
break
if len(result) < self.backupCount:
result = []
else: