mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-12-01 14:58:47 +03:00
Fix crash on invalid utf8 in decrypted events
This commit is contained in:
parent
e8e48305c8
commit
6222ae88ce
1 changed files with 13 additions and 13 deletions
|
@ -1048,6 +1048,7 @@ decryptEvent(const MegolmSessionIndex &index,
|
||||||
return {DecryptionErrorCode::DecryptionFailed, e.what(), std::nullopt};
|
return {DecryptionErrorCode::DecryptionFailed, e.what(), std::nullopt};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
// Add missing fields for the event.
|
// Add missing fields for the event.
|
||||||
json body = json::parse(msg_str);
|
json body = json::parse(msg_str);
|
||||||
body["event_id"] = event.event_id;
|
body["event_id"] = event.event_id;
|
||||||
|
@ -1059,13 +1060,12 @@ decryptEvent(const MegolmSessionIndex &index,
|
||||||
mtx::common::add_relations(body["content"], event.content.relations);
|
mtx::common::add_relations(body["content"], event.content.relations);
|
||||||
|
|
||||||
mtx::events::collections::TimelineEvent te;
|
mtx::events::collections::TimelineEvent te;
|
||||||
try {
|
|
||||||
mtx::events::collections::from_json(body, te);
|
mtx::events::collections::from_json(body, te);
|
||||||
|
|
||||||
|
return {std::nullopt, std::nullopt, std::move(te.data)};
|
||||||
} catch (std::exception &e) {
|
} catch (std::exception &e) {
|
||||||
return {DecryptionErrorCode::ParsingFailed, e.what(), std::nullopt};
|
return {DecryptionErrorCode::ParsingFailed, e.what(), std::nullopt};
|
||||||
}
|
}
|
||||||
|
|
||||||
return {std::nullopt, std::nullopt, std::move(te.data)};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
crypto::Trust
|
crypto::Trust
|
||||||
|
|
Loading…
Reference in a new issue