fix regression of message filters not matching without formatting

This commit is contained in:
jesopo 2020-04-08 18:19:06 +01:00
parent 5df8df83ad
commit 7fdb9a1e55
2 changed files with 11 additions and 9 deletions

View file

@ -31,14 +31,16 @@ class Module(ModuleManager.BaseModule):
filters = self._get_filters(event["server"], target) filters = self._get_filters(event["server"], target)
for filter in filters: for filter in filters:
sed = utils.parse.sed.parse(filter) sed = utils.parse.sed.parse(filter)
type, out = utils.parse.sed.sed(sed, message)
if type == "m" and out: if sed.type == "m":
out = utils.parse.sed.sed(sed, message_plain)
if out:
self.log.info("Message matched filter, dropping: %s" self.log.info("Message matched filter, dropping: %s"
% event["line"].format()) % event["line"].format())
event["line"].invalidate() event["line"].invalidate()
return return
elif type == "s": elif sed.type == "s":
out = utils.parse.sed.sed(sed, message)
message = out message = out
if not message == original_message: if not message == original_message:

View file

@ -76,6 +76,6 @@ def parse(sed_s: str) -> typing.Optional[Sed]:
return SedMatch(type, re.compile(pattern, flags)) return SedMatch(type, re.compile(pattern, flags))
return None return None
def sed(sed_obj: Sed, s: str) -> typing.Tuple[str, typing.Optional[str]]: def sed(sed_obj: Sed, s: str) -> typing.Optional[str]:
out = sed_obj.match(s) out = sed_obj.match(s)
return sed_obj.type, out return out