From 20611e26f8cb34c2a51104466a9a4436291cc5d9 Mon Sep 17 00:00:00 2001 From: Pauli Jokela Date: Mon, 20 Feb 2017 13:35:52 +0200 Subject: [PATCH] Strip HTML tags from chat messages --- js/chat.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/js/chat.js b/js/chat.js index 3f60d1e..8a3c2d6 100644 --- a/js/chat.js +++ b/js/chat.js @@ -20,6 +20,7 @@ function ChatController( $scope, rconService, $timeout ) $scope.OnMessage = function( msg ) { + msg.Message = stripHtml(msg.Message); $scope.Output.push( msg ); if($scope.isOnBottom()) { @@ -76,4 +77,12 @@ function ChatController( $scope, rconService, $timeout ) } rconService.InstallService( $scope, $scope.GetHistory ) +} + +function stripHtml(html) +{ + if (html == null) return ""; + var tmp = document.createElement("div"); + tmp.innerHTML = html; + return tmp.textContent || tmp.innerText || ""; } \ No newline at end of file