mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2025-06-29 15:34:35 +02:00
fix: Additional sanity checks when creating a PDU
Some checks failed
Documentation / Build and Deploy Documentation (push) Has been skipped
Checks / Prefligit / prefligit (push) Failing after 2s
Release Docker Image / define-variables (push) Failing after 1s
Release Docker Image / build-image (linux/amd64, release, linux-amd64, base) (push) Has been skipped
Release Docker Image / build-image (linux/arm64, release, linux-arm64, base) (push) Has been skipped
Release Docker Image / merge (push) Has been skipped
Checks / Rust / Format (push) Failing after 6s
Checks / Rust / Clippy (push) Failing after 27s
Checks / Rust / Cargo Test (push) Failing after 26s
Some checks failed
Documentation / Build and Deploy Documentation (push) Has been skipped
Checks / Prefligit / prefligit (push) Failing after 2s
Release Docker Image / define-variables (push) Failing after 1s
Release Docker Image / build-image (linux/amd64, release, linux-amd64, base) (push) Has been skipped
Release Docker Image / build-image (linux/arm64, release, linux-arm64, base) (push) Has been skipped
Release Docker Image / merge (push) Has been skipped
Checks / Rust / Format (push) Failing after 6s
Checks / Rust / Clippy (push) Failing after 27s
Checks / Rust / Cargo Test (push) Failing after 26s
Prevents creating events that are most likely catastrophically invalid
This commit is contained in:
parent
c82ea24069
commit
543ab27747
1 changed files with 12 additions and 0 deletions
|
@ -719,6 +719,18 @@ impl Service {
|
|||
);
|
||||
}
|
||||
}
|
||||
if event_type != TimelineEventType::RoomCreate && prev_events.is_empty() {
|
||||
return Err!(Request(Unknown("Event incorrectly had zero prev_events.")));
|
||||
}
|
||||
if state_key.is_none() && depth.le(&uint!(2)) {
|
||||
// The first two events in a room are always m.room.create and m.room.member,
|
||||
// so any other events with that same depth are illegal.
|
||||
warn!(
|
||||
"Had unsafe depth {depth} when creating non-state event in {room_id}. Cowardly \
|
||||
aborting"
|
||||
);
|
||||
return Err!(Request(Unknown("Unsafe depth for non-state event.")));
|
||||
}
|
||||
|
||||
let mut pdu = PduEvent {
|
||||
event_id: ruma::event_id!("$thiswillbefilledinlater").into(),
|
||||
|
|
Loading…
Add table
Reference in a new issue