mirror of https://github.com/fail2ban/fail2ban
[BF] prevents always converting of calling map items in replaceTag (without direct access of item):
substituteRecursiveTags: ignore replacing callable items from calling map - should be converted on demand only (by get)pull/1716/head
parent
92d83274d9
commit
c1da6611ec
|
@ -240,6 +240,7 @@ def substituteRecursiveTags(inptags, conditional='',
|
|||
# init:
|
||||
ignore = set(ignore)
|
||||
done = set()
|
||||
calmap = hasattr(tags, "getRawItem")
|
||||
# repeat substitution while embedded-recursive (repFlag is True)
|
||||
while True:
|
||||
repFlag = False
|
||||
|
@ -247,6 +248,8 @@ def substituteRecursiveTags(inptags, conditional='',
|
|||
for tag in tags.iterkeys():
|
||||
# ignore escaped or already done (or in ignore list):
|
||||
if tag in ignore or tag in done: continue
|
||||
# ignore replacing callable items from calling map - should be converted on demand only (by get):
|
||||
if calmap and callable(tags.getRawItem(tag)): continue
|
||||
value = orgval = str(tags[tag])
|
||||
# search and replace all tags within value, that can be interpolated using other tags:
|
||||
m = tre_search(value)
|
||||
|
|
|
@ -98,6 +98,13 @@ class CallingMap(MutableMapping, object):
|
|||
except:
|
||||
return dict(self.data, **self.storage)
|
||||
|
||||
def getRawItem(self, key):
|
||||
try:
|
||||
value = self.storage[key]
|
||||
except KeyError:
|
||||
value = self.data[key]
|
||||
return value
|
||||
|
||||
def __getitem__(self, key):
|
||||
try:
|
||||
value = self.storage[key]
|
||||
|
|
Loading…
Reference in New Issue