diff options
author | Andrew Morgan <andrew@amorgan.xyz> | 2020-02-20 15:49:15 +0000 |
---|---|---|
committer | Andrew Morgan <andrew@amorgan.xyz> | 2020-02-20 15:49:15 +0000 |
commit | e7ffd4a783da8af8c4770e2192eaed487549a028 (patch) | |
tree | fa502d85659ef5c98d1e8f5aca7d66ef05f5d221 /synapse/events | |
parent | Merge pull request #5801 from matrix-org/erikj/recursive_tombstone (diff) | |
parent | Merge pull request #5805 from matrix-org/erikj/validate_state (diff) | |
download | synapse-e7ffd4a783da8af8c4770e2192eaed487549a028.tar.xz |
Merge pull request #5805 from matrix-org/erikj/validate_state
Diffstat (limited to 'synapse/events')
-rw-r--r-- | synapse/events/validator.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/synapse/events/validator.py b/synapse/events/validator.py index 9f2ba7218a..9b90c9ce04 100644 --- a/synapse/events/validator.py +++ b/synapse/events/validator.py @@ -189,10 +189,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") @@ -200,6 +200,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") @@ -209,9 +210,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,)) |