From d6109b95fb979bb53baf4a2b71dcce822c9feaf6 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Mon, 19 Apr 2021 11:20:34 +0200 Subject: Escape html in topics and show line breaks in the settings --- src/RoomsModel.cpp | 5 +++-- src/timeline/TimelineModel.cpp | 13 +++++++++---- src/ui/RoomSettings.cpp | 5 +++-- 3 files changed, 15 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/RoomsModel.cpp b/src/RoomsModel.cpp index 28ffb6e1..5df756f1 100644 --- a/src/RoomsModel.cpp +++ b/src/RoomsModel.cpp @@ -62,10 +62,11 @@ RoomsModel::data(const QModelIndex &index, int role) const case CompletionModel::SearchRole: case Qt::DisplayRole: case Roles::RoomAlias: - return roomAliases[index.row()]; + return roomAliases[index.row()].toHtmlEscaped(); case CompletionModel::SearchRole2: case Roles::RoomName: - return QString::fromStdString(roomInfos.at(roomids[index.row()]).name); + return QString::fromStdString(roomInfos.at(roomids[index.row()]).name) + .toHtmlEscaped(); case Roles::AvatarUrl: return QString::fromStdString( roomInfos.at(roomids[index.row()]).avatar_url); diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index 6108df1c..bfd95b0d 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -474,9 +474,13 @@ TimelineModel::data(const mtx::events::collections::TimelineEvents &event, int r case RoomId: return QVariant(room_id_); case RoomName: - return QVariant(QString::fromStdString(room_name(event))); + return QVariant( + utils::replaceEmoji(QString::fromStdString(room_name(event)).toHtmlEscaped())); case RoomTopic: - return QVariant(QString::fromStdString(room_topic(event))); + return QVariant(utils::replaceEmoji( + utils::linkifyMessage(QString::fromStdString(room_topic(event)) + .toHtmlEscaped() + .replace("\n", "
")))); case CallType: return QVariant(QString::fromStdString(call_type(event))); case Dump: { @@ -1633,7 +1637,8 @@ TimelineModel::roomName() const if (!info.count(room_id_)) return ""; else - return QString::fromStdString(info[room_id_].name); + return utils::replaceEmoji( + QString::fromStdString(info[room_id_].name).toHtmlEscaped()); } QString @@ -1656,5 +1661,5 @@ TimelineModel::roomTopic() const return ""; else return utils::replaceEmoji(utils::linkifyMessage( - utils::escapeBlacklistedHtml(QString::fromStdString(info[room_id_].topic)))); + QString::fromStdString(info[room_id_].topic).toHtmlEscaped())); } diff --git a/src/ui/RoomSettings.cpp b/src/ui/RoomSettings.cpp index cb82cc4e..0bc8759e 100644 --- a/src/ui/RoomSettings.cpp +++ b/src/ui/RoomSettings.cpp @@ -227,13 +227,14 @@ RoomSettings::RoomSettings(QString roomid, QObject *parent) QString RoomSettings::roomName() const { - return QString::fromStdString(info_.name); + return utils::replaceEmoji(QString::fromStdString(info_.name).toHtmlEscaped()); } QString RoomSettings::roomTopic() const { - return utils::linkifyMessage(QString::fromStdString(info_.topic).toHtmlEscaped()); + return utils::replaceEmoji(utils::linkifyMessage( + QString::fromStdString(info_.topic).toHtmlEscaped().replace("\n", "
"))); } QString -- cgit 1.4.1