Skip to content

Commit

Permalink
BF: escape the content of <matches> since its value could contain arb…
Browse files Browse the repository at this point in the history
…itrary symbols
  • Loading branch information
yarikoptic committed Oct 9, 2012
1 parent 6ee2c0a commit 83109bc
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions server/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,14 @@ def getActionStop(self):
def execActionStop(self):
stopCmd = Action.replaceTag(self.__actionStop, self.__cInfo)
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.
#
Expand All @@ -243,8 +250,13 @@ def replaceTag(query, aInfo):
""" Replace tags in query
"""
string = query
for tag in aInfo:
string = string.replace('<' + tag + '>', str(aInfo[tag]))
for tag, value in aInfo.iteritems():
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
string = string.replace("<br>", '\n')
return string
Expand Down

0 comments on commit 83109bc

Please sign in to comment.