diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2019-01-10 16:46:57 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2019-01-13 17:19:00 +0900 |
commit | ebe43ac929393787a9a55cf7569b540c73f8048c (patch) | |
tree | ec3a784677562a38ff6aa33434cc1765276dcf94 /lib/events/stateevent.cpp | |
parent | 8ad8a74152c5701b6ca1f9a00487ba9257a439b4 (diff) | |
download | libquotient-ebe43ac929393787a9a55cf7569b540c73f8048c.tar.gz libquotient-ebe43ac929393787a9a55cf7569b540c73f8048c.zip |
Security fix: require that state events have state_key
This has been fixed in the past but got undone after the great remaking of the event types system. Further commits will introduce tests to make sure this does not get undone again.
# Conflicts:
# lib/events/stateevent.cpp
Diffstat (limited to 'lib/events/stateevent.cpp')
-rw-r--r-- | lib/events/stateevent.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/events/stateevent.cpp b/lib/events/stateevent.cpp index fd5d2642..877d0fae 100644 --- a/lib/events/stateevent.cpp +++ b/lib/events/stateevent.cpp @@ -21,7 +21,17 @@ using namespace QMatrixClient; [[gnu::unused]] static auto stateEventTypeInitialised = - RoomEvent::factory_t::chainFactory<StateEventBase>(); + RoomEvent::factory_t::addMethod( + [] (const QJsonObject& json, const QString& matrixType) -> StateEventPtr + { + if (!json.contains("state_key")) + return nullptr; + + if (auto e = StateEventBase::factory_t::make(json, matrixType)) + return e; + + return nullptr; + }); bool StateEventBase::repeatsState() const { |