feat: Escape @room in the reply fallback when replying
This commit is contained in:
parent
3f2ced692f
commit
6d171542af
|
|
@ -784,7 +784,10 @@ class Room {
|
||||||
.replaceAll('\n', '<br>'));
|
.replaceAll('\n', '<br>'));
|
||||||
content['formatted_body'] =
|
content['formatted_body'] =
|
||||||
'<mx-reply><blockquote><a href="https://matrix.to/#/${inReplyTo.room.id}/${inReplyTo.eventId}">In reply to</a> <a href="https://matrix.to/#/${inReplyTo.senderId}">${inReplyTo.senderId}</a><br>$replyHtml</blockquote></mx-reply>$repliedHtml';
|
'<mx-reply><blockquote><a href="https://matrix.to/#/${inReplyTo.room.id}/${inReplyTo.eventId}">In reply to</a> <a href="https://matrix.to/#/${inReplyTo.senderId}">${inReplyTo.senderId}</a><br>$replyHtml</blockquote></mx-reply>$repliedHtml';
|
||||||
content['body'] = replyText + "\n\n${content.tryGet<String>('body', '')}";
|
// We escape all @room-mentions here to prevent accidental room pings when an admin
|
||||||
|
// replies to a message containing that!
|
||||||
|
content['body'] =
|
||||||
|
'${replyText.replaceAll('@room', '@\u200broom')}\n\n${content.tryGet<String>('body', '')}';
|
||||||
content['m.relates_to'] = {
|
content['m.relates_to'] = {
|
||||||
'm.in_reply_to': {
|
'm.in_reply_to': {
|
||||||
'event_id': inReplyTo.eventId,
|
'event_id': inReplyTo.eventId,
|
||||||
|
|
|
||||||
|
|
@ -499,6 +499,35 @@ void main() {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
event = Event.fromJson({
|
||||||
|
'event_id': '\$replyEvent',
|
||||||
|
'content': {
|
||||||
|
'body': 'Hey @room',
|
||||||
|
'msgtype': 'm.text',
|
||||||
|
},
|
||||||
|
'type': 'm.room.message',
|
||||||
|
'sender': '@alice:example.org',
|
||||||
|
}, room);
|
||||||
|
FakeMatrixApi.calledEndpoints.clear();
|
||||||
|
resp = await room.sendTextEvent('Hello world',
|
||||||
|
txid: 'testtxid', inReplyTo: event);
|
||||||
|
expect(resp.startsWith('\$event'), true);
|
||||||
|
entry = FakeMatrixApi.calledEndpoints.entries
|
||||||
|
.firstWhere((p) => p.key.contains('/send/m.room.message/'));
|
||||||
|
content = json.decode(entry.value.first);
|
||||||
|
expect(content, {
|
||||||
|
'body': '> <@alice:example.org> Hey @\u{200b}room\n\nHello world',
|
||||||
|
'msgtype': 'm.text',
|
||||||
|
'format': 'org.matrix.custom.html',
|
||||||
|
'formatted_body':
|
||||||
|
'<mx-reply><blockquote><a href="https://matrix.to/#/!localpart:server.abc/\$replyEvent">In reply to</a> <a href="https://matrix.to/#/@alice:example.org">@alice:example.org</a><br>Hey @room</blockquote></mx-reply>Hello world',
|
||||||
|
'm.relates_to': {
|
||||||
|
'm.in_reply_to': {
|
||||||
|
'event_id': '\$replyEvent',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('send reaction', () async {
|
test('send reaction', () async {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue