Skip to content

Commit e7bd0ae

Browse files
committed
Fix HTML escaping artefacts
1 parent ec26fae commit e7bd0ae

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

client/models/messageeventmodel.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,8 @@ QVariant MessageEventModel::data(const QModelIndex& idx, int role) const
449449
}
450450
, [this] (const RoomMemberEvent& e) {
451451
// FIXME: Rewind to the name that was at the time of this event
452-
auto subjectName = m_currentRoom->safeMemberName(e.userId());
452+
const auto subjectName =
453+
m_currentRoom->safeMemberName(e.userId()).toHtmlEscaped();
453454
// The below code assumes senderName output in AuthorRole
454455
switch( e.membership() )
455456
{

client/qml/TimelineItem.qml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ Item {
157157
elide: Text.ElideRight
158158

159159
color: textColor
160+
textFormat: Label.PlainText
160161
font.bold: !xchatStyle
161162
renderType: settings.render_type
162163

@@ -234,14 +235,23 @@ Item {
234235
rightPadding: 2
235236
x: -textScrollBar.position * contentWidth
236237

238+
// Doesn't work for attributes
239+
function toHtmlEscaped(txt) {
240+
// Make sure to replace & first
241+
var eTxt = txt.replace(/&/g, '&')
242+
.replace(/</g, '&lt;').replace(/>/g, '&gt;')
243+
console.log(eTxt)
244+
return eTxt
245+
}
246+
237247
selectByMouse: true
238248
readOnly: true
239249
textFormat: TextEdit.RichText
240250
// FIXME: The text is clumsy and slows down creation
241251
text: (actionEvent && !xchatStyle ?
242252
("<a href='#mention' style='text-decoration:none;color:\"" +
243253
defaultPalette.text + "\"'><b>" +
244-
authorName + "</b></a> ") : ""
254+
toHtmlEscaped(authorName) + "</b></a> ") : ""
245255
) + display +
246256
(annotation ? "<br><em>" + annotation + "</em>" : "")
247257
horizontalAlignment: Text.AlignLeft

client/quaternionroom.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ bool QuaternionRoom::canSwitchVersions() const
9999

100100
QString QuaternionRoom::safeMemberName(const QString& userId) const
101101
{
102-
return sanitized(roomMembername(userId)).toHtmlEscaped();
102+
return sanitized(roomMembername(userId));
103103
}
104104

105105
void QuaternionRoom::countChanged()

0 commit comments

Comments
 (0)