Add validity checks for mentions before inserting them into the message

For yet unknown reasons, sometimes invalid mentions are inserted into the list, which will mess up all further messages. While finding those bugs is the better approach, these checks should also be useful.
This commit is contained in:
Tobias Fella
2022-11-07 16:34:33 +01:00
parent c03b69cd17
commit 089c6c1a46

View File

@@ -77,10 +77,14 @@ void ActionsHandler::handleMessage()
});
for (const auto &mention : *m_room->mentions()) {
if (mention.text.isEmpty() || mention.id.isEmpty()) {
continue;
}
handledText = handledText.replace(mention.cursor.anchor(),
mention.cursor.position() - mention.cursor.anchor(),
QStringLiteral("[%1](https://matrix.to/#/%2)").arg(mention.text, mention.id));
}
m_room->mentions()->clear();
if (NeoChatConfig::allowQuickEdit()) {
QRegularExpression sed("^s/([^/]*)/([^/]*)(/g)?$");