From 768e270f3f38f71b9fcb49b1e12dfdea133b226f Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 29 Nov 2021 17:18:04 +0000 Subject: [PATCH] Improve room list message previews (#7224) --- src/stores/room-list/previews/MessageEventPreview.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/stores/room-list/previews/MessageEventPreview.ts b/src/stores/room-list/previews/MessageEventPreview.ts index b8e3119ad4..ad82ba1ea6 100644 --- a/src/stores/room-list/previews/MessageEventPreview.ts +++ b/src/stores/room-list/previews/MessageEventPreview.ts @@ -55,7 +55,9 @@ export class MessageEventPreview implements IPreview { } if (hasHtml) { - body = getHtmlText(body); + const sanitised = getHtmlText(body.replace(//gi, "\n")); // replace line breaks before removing them + // run it through DOMParser to fixup encoded html entities + body = new DOMParser().parseFromString(sanitised, "text/html").documentElement.textContent; } body = sanitizeForTranslation(body);