summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2019-08-01 13:45:48 +0100
committerGitHub <noreply@github.com>2019-08-01 13:45:48 +0100
commit55a0c98d1690f7c2aa021519393dbffba252715a (patch)
treee4512a414f8824564de423e5ebbfe01e49dc2cd2 /synapse
parentMerge pull request #5801 from matrix-org/erikj/recursive_tombstone (diff)
parentNewsfile (diff)
downloadsynapse-55a0c98d1690f7c2aa021519393dbffba252715a.tar.xz
Merge pull request #5805 from matrix-org/erikj/validate_state
Validate well known state events are state events.
Diffstat (limited to 'synapse')
-rw-r--r--synapse/events/validator.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/synapse/events/validator.py b/synapse/events/validator.py
index 6374dd067d..272426e105 100644
--- a/synapse/events/validator.py
+++ b/synapse/events/validator.py
@@ -95,10 +95,10 @@ class EventValidator(object):
 
         elif event.type == EventTypes.Topic:
             self._ensure_strings(event.content, ["topic"])
-
+            self._ensure_state_event(event)
         elif event.type == EventTypes.Name:
             self._ensure_strings(event.content, ["name"])
-
+            self._ensure_state_event(event)
         elif event.type == EventTypes.Member:
             if "membership" not in event.content:
                 raise SynapseError(400, "Content has not membership key")
@@ -106,6 +106,7 @@ class EventValidator(object):
             if event.content["membership"] not in Membership.LIST:
                 raise SynapseError(400, "Invalid membership key")
 
+            self._ensure_state_event(event)
         elif event.type == EventTypes.Tombstone:
             if "replacement_room" not in event.content:
                 raise SynapseError(400, "Content has no replacement_room key")
@@ -115,9 +116,15 @@ class EventValidator(object):
                     400, "Tombstone cannot reference the room it was sent in"
                 )
 
+            self._ensure_state_event(event)
+
     def _ensure_strings(self, d, keys):
         for s in keys:
             if s not in d:
                 raise SynapseError(400, "'%s' not in content" % (s,))
             if not isinstance(d[s], string_types):
                 raise SynapseError(400, "'%s' not a string type" % (s,))
+
+    def _ensure_state_event(self, event):
+        if not event.is_state():
+            raise SynapseError(400, "'%s' must be state events" % (event.type,))