mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-25 20:48:52 +03:00
Temporary fix to work with mx-reply tags
This commit is contained in:
parent
bf4d559523
commit
9f3de8679d
2 changed files with 15 additions and 6 deletions
|
@ -285,7 +285,14 @@ utils::humanReadableFingerprint(const QString &ed25519)
|
|||
QString
|
||||
utils::linkifyMessage(const QString &body)
|
||||
{
|
||||
QXmlStreamReader xml{"<html>" + body + "</html>"};
|
||||
// Convert to valid XML.
|
||||
auto doc = QString("<html>%1</html>").arg(body);
|
||||
|
||||
doc.replace("<mx-reply>", "");
|
||||
doc.replace("</mx-reply>", "");
|
||||
doc.replace("<br>", "<br></br>");
|
||||
|
||||
QXmlStreamReader xml{doc};
|
||||
|
||||
QString textString;
|
||||
while (!xml.atEnd() && !xml.hasError()) {
|
||||
|
@ -330,8 +337,10 @@ utils::linkifyMessage(const QString &body)
|
|||
}
|
||||
|
||||
if (xml.hasError()) {
|
||||
// qWarning() << "error while parsing xml";
|
||||
return body;
|
||||
qWarning() << "error while parsing xml" << xml.errorString() << doc;
|
||||
doc.replace("<html>", "");
|
||||
doc.replace("</html>", "");
|
||||
return doc;
|
||||
}
|
||||
|
||||
return textString;
|
||||
|
|
|
@ -494,7 +494,7 @@ TimelineItem::TimelineItem(const mtx::events::RoomEvent<mtx::events::msg::Notice
|
|||
const auto timestamp = QDateTime::fromMSecsSinceEpoch(event.origin_server_ts);
|
||||
|
||||
auto formatted_body = utils::linkifyMessage(utils::getMessageBody(event).trimmed());
|
||||
auto body = QString::fromStdString(event.content.body).trimmed();
|
||||
auto body = QString::fromStdString(event.content.body).trimmed().toHtmlEscaped();
|
||||
|
||||
descriptionMsg_ = {Cache::displayName(room_id_, sender),
|
||||
sender,
|
||||
|
@ -539,7 +539,7 @@ TimelineItem::TimelineItem(const mtx::events::RoomEvent<mtx::events::msg::Emote>
|
|||
const auto sender = QString::fromStdString(event.sender);
|
||||
|
||||
auto formatted_body = utils::linkifyMessage(utils::getMessageBody(event).trimmed());
|
||||
auto body = QString::fromStdString(event.content.body).trimmed();
|
||||
auto body = QString::fromStdString(event.content.body).trimmed().toHtmlEscaped();
|
||||
|
||||
auto timestamp = QDateTime::fromMSecsSinceEpoch(event.origin_server_ts);
|
||||
auto displayName = Cache::displayName(room_id_, sender);
|
||||
|
@ -586,7 +586,7 @@ TimelineItem::TimelineItem(const mtx::events::RoomEvent<mtx::events::msg::Text>
|
|||
const auto sender = QString::fromStdString(event.sender);
|
||||
|
||||
auto formatted_body = utils::linkifyMessage(utils::getMessageBody(event).trimmed());
|
||||
auto body = QString::fromStdString(event.content.body).trimmed();
|
||||
auto body = QString::fromStdString(event.content.body).trimmed().toHtmlEscaped();
|
||||
|
||||
auto timestamp = QDateTime::fromMSecsSinceEpoch(event.origin_server_ts);
|
||||
auto displayName = Cache::displayName(room_id_, sender);
|
||||
|
|
Loading…
Reference in a new issue