aboutsummaryrefslogtreecommitdiff
path: root/lib/events/stateevent.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2019-01-10 16:46:57 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2019-01-13 18:02:23 +0900
commit4c30996f28bfb6507eb5fb6f730a8769f8d964e3 (patch)
treef2b6eea3c6546f7e7f49f9ab7951765266b7fa16 /lib/events/stateevent.cpp
parent3cb7982fda8c0049eff51a9ab65eb43667e2c4ce (diff)
downloadlibquotient-4c30996f28bfb6507eb5fb6f730a8769f8d964e3.tar.gz
libquotient-4c30996f28bfb6507eb5fb6f730a8769f8d964e3.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.
Diffstat (limited to 'lib/events/stateevent.cpp')
-rw-r--r--lib/events/stateevent.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/events/stateevent.cpp b/lib/events/stateevent.cpp
index c4151676..e96614d2 100644
--- a/lib/events/stateevent.cpp
+++ b/lib/events/stateevent.cpp
@@ -25,13 +25,15 @@ using namespace QMatrixClient;
// but the event type is unknown.
[[gnu::unused]] static auto stateEventTypeInitialised =
RoomEvent::factory_t::addMethod(
- [] (const QJsonObject& json, const QString& matrixType)
+ [] (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 json.contains("state_key")
- ? makeEvent<StateEventBase>(unknownEventTypeId(), json)
- : nullptr;
+
+ return makeEvent<StateEventBase>(unknownEventTypeId(), json);
});
bool StateEventBase::repeatsState() const