summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--synapse/push/__init__.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/synapse/push/__init__.py b/synapse/push/__init__.py
index 07b5f0187c..6f143a5df9 100644
--- a/synapse/push/__init__.py
+++ b/synapse/push/__init__.py
@@ -147,11 +147,14 @@ class Pusher(object):
                 logger.warn("event_match condition with no pattern")
                 return False
             # XXX: optimisation: cache our pattern regexps
-            r = r'\b%s\b' % self._glob_to_regexp(condition['pattern'])
+            if condition['key'] == 'content.body':
+                r = r'\b%s\b' % self._glob_to_regexp(condition['pattern'])
+            else:
+                r = r'^%s$' % self._glob_to_regexp(condition['pattern'])
             val = _value_for_dotted_key(condition['key'], ev)
             if val is None:
                 return False
-            return re.match(r, val, flags=re.IGNORECASE) != None
+            return re.search(r, val, flags=re.IGNORECASE) is not None
 
         elif condition['kind'] == 'device':
             if 'profile_tag' not in condition:
@@ -167,8 +170,8 @@ class Pusher(object):
                 return False
             if not display_name:
                 return False
-            return re.match("\b%s\b" % re.escape(display_name),
-                            ev['content']['body'], flags=re.IGNORECASE) != None
+            return re.search("\b%s\b" % re.escape(display_name),
+                            ev['content']['body'], flags=re.IGNORECASE) is not None
 
         elif condition['kind'] == 'room_member_count':
             if 'is' not in condition: