From a6529b040c66d71aaedb0e2971a7c5cae2f204cd Mon Sep 17 00:00:00 2001 From: miruka Date: Tue, 2 Jun 2020 22:03:22 -0400 Subject: [PATCH] Fix handling topics containing \n, \t or --- CHANGELOG.md | 3 +++ src/backend/matrix_client.py | 4 +++- src/backend/nio_callbacks.py | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87b4dbc6..81243f4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -83,6 +83,9 @@ and this project adheres to - When signing in a new account, correctly position it after the other existing ones without needing a restart +- Correctly handle room topics containing new lines, hard tabs or text inside + `<>` brackets + ## 0.5.0 ### Added diff --git a/src/backend/matrix_client.py b/src/backend/matrix_client.py index d9c3926d..b585bcf1 100644 --- a/src/backend/matrix_client.py +++ b/src/backend/matrix_client.py @@ -1276,7 +1276,9 @@ class MatrixClient(nio.AsyncClient): avatar_url = room.gen_avatar_url or "", plain_topic = room.topic or "", topic = HTML.filter( - room.topic or "", inline=True, room_id=room.room_id, + utils.plain2html(room.topic or ""), + inline = True, + room_id = room.room_id, ), inviter_id = inviter, inviter_name = room.user_name(inviter) if inviter else "", diff --git a/src/backend/nio_callbacks.py b/src/backend/nio_callbacks.py index 83ebd2a6..e7fbbb3c 100644 --- a/src/backend/nio_callbacks.py +++ b/src/backend/nio_callbacks.py @@ -451,7 +451,7 @@ class NioCallbacks: ) -> None: if ev.topic: topic = HTML_PROCESSOR.filter( - ev.topic, inline=True, room_id=room.room_id, + plain2html(ev.topic), inline=True, room_id=room.room_id, ) co = f"%1 changed the room's topic to \"{topic}\"" else: