From 9fee93a100606111a24e86be45ddf7b3134ca879 Mon Sep 17 00:00:00 2001 From: Miroslav Pejic Date: Tue, 14 Jun 2022 08:39:28 +0200 Subject: [PATCH] [mirotalksfu] - chat - strip Html --- public/js/RoomClient.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/public/js/RoomClient.js b/public/js/RoomClient.js index fdf3f8b8..987eea08 100644 --- a/public/js/RoomClient.js +++ b/public/js/RoomClient.js @@ -1800,10 +1800,7 @@ class RoomClient { } formatMsg(message) { - if (message.includes(' { if (message.match(/\.(jpeg|jpg|gif|png|tiff|bmp)$/)) @@ -1812,6 +1809,20 @@ class RoomClient { }); } + stripHtml(html) { + let doc = new DOMParser().parseFromString(html, 'text/html'); + return doc.body.textContent || ''; + } + + isHtml(str) { + var a = document.createElement('div'); + a.innerHTML = str; + for (var c = a.childNodes, i = c.length; i--; ) { + if (c[i].nodeType == 1) return true; + } + return false; + } + collectMessages(time, from, msg) { this.chatMessages.push({ time: time,