diff --git a/imports/NeoChat/Page/RoomPage.qml b/imports/NeoChat/Page/RoomPage.qml index 5fab8a3fb..123759fe0 100644 --- a/imports/NeoChat/Page/RoomPage.qml +++ b/imports/NeoChat/Page/RoomPage.qml @@ -26,7 +26,7 @@ Kirigami.ScrollablePage { /// Used to determine if scrolling to the bottom should mark the message as unread property bool hasScrolledUpBefore: false; - title: currentRoom.displayName + title: currentRoom.htmlSafeDisplayName Connections { target: RoomManager diff --git a/src/neochatroom.cpp b/src/neochatroom.cpp index 04d27439d..95bf657e0 100644 --- a/src/neochatroom.cpp +++ b/src/neochatroom.cpp @@ -53,6 +53,7 @@ NeoChatRoom::NeoChatRoom(Connection *connection, QString roomId, JoinState joinS Q_EMIT isInviteChanged(); } }); + connect(this, &Room::displaynameChanged, this, &NeoChatRoom::displayNameChanged); } void NeoChatRoom::uploadFile(const QUrl &url, const QString &body) @@ -710,3 +711,13 @@ bool NeoChatRoom::isUserBanned(const QString &user) const { return getCurrentState(user)->membership() == MembershipType::Ban; } + +QString NeoChatRoom::htmlSafeName() const +{ + return name().toHtmlEscaped(); +} + +QString NeoChatRoom::htmlSafeDisplayName() const +{ + return displayName().toHtmlEscaped(); +} \ No newline at end of file diff --git a/src/neochatroom.h b/src/neochatroom.h index 99a30cd8c..16d597d40 100644 --- a/src/neochatroom.h +++ b/src/neochatroom.h @@ -31,6 +31,7 @@ class NeoChatRoom : public Room Q_PROPERTY(bool readMarkerLoaded READ readMarkerLoaded NOTIFY readMarkerLoadedChanged) Q_PROPERTY(QDateTime lastActiveTime READ lastActiveTime NOTIFY lastActiveTimeChanged) Q_PROPERTY(bool isInvite READ isInvite NOTIFY isInviteChanged) + Q_PROPERTY(QString htmlSafeDisplayName READ htmlSafeDisplayName NOTIFY displayNameChanged) public: explicit NeoChatRoom(Connection *connection, QString roomId, JoinState joinState = {}); @@ -112,6 +113,9 @@ public: bool isInvite() const; + Q_INVOKABLE QString htmlSafeName() const; + Q_INVOKABLE QString htmlSafeDisplayName() const; + #ifndef QUOTIENT_07 Q_INVOKABLE QString htmlSafeMemberName(const QString &userId) const { @@ -146,6 +150,7 @@ Q_SIGNALS: void readMarkerLoadedChanged(); void lastActiveTimeChanged(); void isInviteChanged(); + void displayNameChanged(); public Q_SLOTS: void uploadFile(const QUrl &url, const QString &body = QString()); diff --git a/src/roomlistmodel.cpp b/src/roomlistmodel.cpp index 93c2e1b21..17511374b 100644 --- a/src/roomlistmodel.cpp +++ b/src/roomlistmodel.cpp @@ -329,7 +329,7 @@ QVariant RoomListModel::data(const QModelIndex &index, int role) const } NeoChatRoom *room = m_rooms.at(index.row()); if (role == NameRole) { - return !room->name().isEmpty() ? room->name() : room->displayName(); + return !room->name().isEmpty() ? room->htmlSafeName() : room->htmlSafeDisplayName(); } if (role == DisplayNameRole) { return room->displayName();