mirror of https://github.com/fail2ban/fail2ban
BF: escape the content of <matches> since its value could contain arbitrary symbols
parent
6ee2c0a014
commit
83109bce14
|
@ -230,7 +230,14 @@ class Action:
|
||||||
def execActionStop(self):
|
def execActionStop(self):
|
||||||
stopCmd = Action.replaceTag(self.__actionStop, self.__cInfo)
|
stopCmd = Action.replaceTag(self.__actionStop, self.__cInfo)
|
||||||
return Action.executeCmd(stopCmd)
|
return Action.executeCmd(stopCmd)
|
||||||
|
|
||||||
|
def escapeTag(tag):
|
||||||
|
for c in '\\#&;`|*?~<>^()[]{}$\n':
|
||||||
|
if c in tag:
|
||||||
|
tag = tag.replace(c, '\\' + c)
|
||||||
|
return tag
|
||||||
|
escapeTag = staticmethod(escapeTag)
|
||||||
|
|
||||||
##
|
##
|
||||||
# Replaces tags in query with property values in aInfo.
|
# Replaces tags in query with property values in aInfo.
|
||||||
#
|
#
|
||||||
|
@ -243,8 +250,13 @@ class Action:
|
||||||
""" Replace tags in query
|
""" Replace tags in query
|
||||||
"""
|
"""
|
||||||
string = query
|
string = query
|
||||||
for tag in aInfo:
|
for tag, value in aInfo.iteritems():
|
||||||
string = string.replace('<' + tag + '>', str(aInfo[tag]))
|
value = str(value) # assure string
|
||||||
|
if tag == 'matches':
|
||||||
|
# That one needs to be escaped since its content is
|
||||||
|
# out of our control
|
||||||
|
value = escapeTag(value)
|
||||||
|
string = string.replace('<' + tag + '>', value)
|
||||||
# New line
|
# New line
|
||||||
string = string.replace("<br>", '\n')
|
string = string.replace("<br>", '\n')
|
||||||
return string
|
return string
|
||||||
|
|
Loading…
Reference in New Issue