Escape html in topics and show line breaks in the settings

This commit is contained in:
Nicolas Werner 2021-04-19 11:20:34 +02:00
parent a792ea1465
commit d6109b95fb
No known key found for this signature in database
GPG Key ID: C8D75E610773F2D9
4 changed files with 17 additions and 9 deletions

View File

@ -72,7 +72,8 @@ Rectangle {
font.pointSize: fontMetrics.font.pointSize * 1.1 font.pointSize: fontMetrics.font.pointSize * 1.1
text: room ? room.roomName : qsTr("No room selected") text: room ? room.roomName : qsTr("No room selected")
maximumLineCount: 1 maximumLineCount: 1
elide: Text.ElideRight elide: Text.ElideRight
textFormat: Text.RichText
} }
MatrixText { MatrixText {

View File

@ -62,10 +62,11 @@ RoomsModel::data(const QModelIndex &index, int role) const
case CompletionModel::SearchRole: case CompletionModel::SearchRole:
case Qt::DisplayRole: case Qt::DisplayRole:
case Roles::RoomAlias: case Roles::RoomAlias:
return roomAliases[index.row()]; return roomAliases[index.row()].toHtmlEscaped();
case CompletionModel::SearchRole2: case CompletionModel::SearchRole2:
case Roles::RoomName: 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: case Roles::AvatarUrl:
return QString::fromStdString( return QString::fromStdString(
roomInfos.at(roomids[index.row()]).avatar_url); roomInfos.at(roomids[index.row()]).avatar_url);

View File

@ -474,9 +474,13 @@ TimelineModel::data(const mtx::events::collections::TimelineEvents &event, int r
case RoomId: case RoomId:
return QVariant(room_id_); return QVariant(room_id_);
case RoomName: case RoomName:
return QVariant(QString::fromStdString(room_name(event))); return QVariant(
utils::replaceEmoji(QString::fromStdString(room_name(event)).toHtmlEscaped()));
case RoomTopic: 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: case CallType:
return QVariant(QString::fromStdString(call_type(event))); return QVariant(QString::fromStdString(call_type(event)));
case Dump: { case Dump: {
@ -1633,7 +1637,8 @@ TimelineModel::roomName() const
if (!info.count(room_id_)) if (!info.count(room_id_))
return ""; return "";
else else
return QString::fromStdString(info[room_id_].name); return utils::replaceEmoji(
QString::fromStdString(info[room_id_].name).toHtmlEscaped());
} }
QString QString
@ -1656,5 +1661,5 @@ TimelineModel::roomTopic() const
return ""; return "";
else else
return utils::replaceEmoji(utils::linkifyMessage( return utils::replaceEmoji(utils::linkifyMessage(
utils::escapeBlacklistedHtml(QString::fromStdString(info[room_id_].topic)))); QString::fromStdString(info[room_id_].topic).toHtmlEscaped()));
} }

View File

@ -227,13 +227,14 @@ RoomSettings::RoomSettings(QString roomid, QObject *parent)
QString QString
RoomSettings::roomName() const RoomSettings::roomName() const
{ {
return QString::fromStdString(info_.name); return utils::replaceEmoji(QString::fromStdString(info_.name).toHtmlEscaped());
} }
QString QString
RoomSettings::roomTopic() const 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 QString