mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 18:22:50 +01:00
ircd:Ⓜ️:event::conforms: Add type and state_key length limitation conditions.
This commit is contained in:
parent
629617deb9
commit
ddbabedf84
2 changed files with 10 additions and 0 deletions
|
@ -61,8 +61,10 @@ enum ircd::m::event::conforms::code
|
||||||
INVALID_OR_MISSING_ROOM_ID, ///< room_id empty or failed mxid grammar check
|
INVALID_OR_MISSING_ROOM_ID, ///< room_id empty or failed mxid grammar check
|
||||||
INVALID_OR_MISSING_SENDER_ID, ///< sender empty or failed mxid grammar check
|
INVALID_OR_MISSING_SENDER_ID, ///< sender empty or failed mxid grammar check
|
||||||
MISSING_TYPE, ///< type empty
|
MISSING_TYPE, ///< type empty
|
||||||
|
INVALID_TYPE, ///< type field invalid or too long
|
||||||
MISSING_ORIGIN, ///< origin empty
|
MISSING_ORIGIN, ///< origin empty
|
||||||
INVALID_ORIGIN, ///< origin not a proper domain
|
INVALID_ORIGIN, ///< origin not a proper domain
|
||||||
|
INVALID_STATE_KEY, ///< state_key invalid or too long
|
||||||
INVALID_OR_MISSING_REDACTS_ID, ///< for m.room.redaction
|
INVALID_OR_MISSING_REDACTS_ID, ///< for m.room.redaction
|
||||||
MISSING_CONTENT_MEMBERSHIP, ///< for m.room.member, content.membership
|
MISSING_CONTENT_MEMBERSHIP, ///< for m.room.member, content.membership
|
||||||
INVALID_CONTENT_MEMBERSHIP, ///< for m.room.member, content.membership
|
INVALID_CONTENT_MEMBERSHIP, ///< for m.room.member, content.membership
|
||||||
|
|
|
@ -156,8 +156,10 @@ ircd::m::event_conforms_reflects
|
||||||
"INVALID_OR_MISSING_ROOM_ID",
|
"INVALID_OR_MISSING_ROOM_ID",
|
||||||
"INVALID_OR_MISSING_SENDER_ID",
|
"INVALID_OR_MISSING_SENDER_ID",
|
||||||
"MISSING_TYPE",
|
"MISSING_TYPE",
|
||||||
|
"INVALID_TYPE",
|
||||||
"MISSING_ORIGIN",
|
"MISSING_ORIGIN",
|
||||||
"INVALID_ORIGIN",
|
"INVALID_ORIGIN",
|
||||||
|
"INVALID_STATE_KEY",
|
||||||
"INVALID_OR_MISSING_REDACTS_ID",
|
"INVALID_OR_MISSING_REDACTS_ID",
|
||||||
"MISSING_CONTENT_MEMBERSHIP",
|
"MISSING_CONTENT_MEMBERSHIP",
|
||||||
"INVALID_CONTENT_MEMBERSHIP",
|
"INVALID_CONTENT_MEMBERSHIP",
|
||||||
|
@ -246,6 +248,9 @@ ircd::m::event::conforms::conforms(const event &e)
|
||||||
if(empty(json::get<"type"_>(e)))
|
if(empty(json::get<"type"_>(e)))
|
||||||
set(MISSING_TYPE);
|
set(MISSING_TYPE);
|
||||||
|
|
||||||
|
if(json::get<"type"_>(e).size() > event::TYPE_MAX_SIZE)
|
||||||
|
set(INVALID_TYPE);
|
||||||
|
|
||||||
if(empty(json::get<"origin"_>(e)))
|
if(empty(json::get<"origin"_>(e)))
|
||||||
set(MISSING_ORIGIN);
|
set(MISSING_ORIGIN);
|
||||||
|
|
||||||
|
@ -255,6 +260,9 @@ ircd::m::event::conforms::conforms(const event &e)
|
||||||
if(!rfc3986::valid_remote(std::nothrow, json::get<"origin"_>(e)))
|
if(!rfc3986::valid_remote(std::nothrow, json::get<"origin"_>(e)))
|
||||||
set(INVALID_ORIGIN);
|
set(INVALID_ORIGIN);
|
||||||
|
|
||||||
|
if(json::get<"state_key"_>(e).size() > event::STATE_KEY_MAX_SIZE)
|
||||||
|
set(INVALID_STATE_KEY);
|
||||||
|
|
||||||
if(empty(json::get<"signatures"_>(e)))
|
if(empty(json::get<"signatures"_>(e)))
|
||||||
set(MISSING_SIGNATURES);
|
set(MISSING_SIGNATURES);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue