summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2021-04-19 11:20:34 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2021-04-19 11:20:52 +0200
commitd6109b95fb979bb53baf4a2b71dcce822c9feaf6 (patch)
tree0c9f16fd69790d7a303ec5800fee1ed30b82edc0 /src
parentBump version to 0.8.2 (diff)
downloadnheko-d6109b95fb979bb53baf4a2b71dcce822c9feaf6.tar.xz
Escape html in topics and show line breaks in the settings
Diffstat (limited to 'src')
-rw-r--r--src/RoomsModel.cpp5
-rw-r--r--src/timeline/TimelineModel.cpp13
-rw-r--r--src/ui/RoomSettings.cpp5
3 files changed, 15 insertions, 8 deletions
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", "<br>"))));
         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", "<br>")));
 }
 
 QString